Reputation: 293
I am using py2exe to make executable.
I want to know how to pause the program until a button is pressed.. just like we do in C using system("pause");
As the program terminates automatically in windows, I need this tool.
Is there anything better than py2exe which does similar work ?
Upvotes: 2
Views: 22546
Reputation: 3904
A quick code snippet to handle both Python 2 and 3:
# -*- coding: utf-8 -*-
import sys
python2 = sys.version_info[0] == 2
if python2:
raw_input("Press ENTER to continue.")
else:
input("Press ENTER to continue.")
Upvotes: 4
Reputation: 725
You can use raw_input in Python2, or input in Python 3
raw_input("Press Enter to terminate.")
Upvotes: 6