What is the Python Equivalent of Batch's
PAUSE
function? The program shall wait for the user to press a key before continuation.
What is the Python Equivalent of Batch's
PAUSE
function? The program shall wait for the user to press a key before continuation.
To pause for a few seconds, take a look at time.sleep
.
To wait for input (you can discard it if you wish), use input
or raw_input
.
To wait for any input, this answer suggests (windows only):
import msvcrt as m
def wait():
m.getch()
A following answer in the same thread suggests using an external tool if it's available (not windows), read
:
os.system('read -s -n 1 -p "Press any key to continue..."')