How would I do a "hit any key" (or grab a menu option) in Python?
Is there a portable way to do this using the standard libs?
try: # Win32 from msvcrt import getch except ImportError: # UNIX def getch(): import sys, tty, termios fd = sys.stdin.fileno() old = termios.tcgetattr(fd) try: tty.setraw(fd) return sys.stdin.read(1) finally: termios.tcsetattr(fd, termios.TCSADRAIN, old)
try: os.system('pause') #windows, doesn't require enter except whatever_it_is: os.system('read -p "Press any key to continue"') #linux
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With