Python Press Enter To Continue

raw_input("Press Go into to continue...")This only waits for the user to push enter though.

One can desire to use msvcrt ((Windows/DOS only) The msvcrt module gives you accessibility to a number of functions in the Microsoft Visual C/C++ Runtime Library (MSVCRT)):

import msvcrt as mdef wait(): m.getch()This need to wait for a key push.

Additional info:

in Python 3 raw_input() does not exist

In Python 2 input(prompt) is tantamount to eval(raw_input(prompt))

You watching: Python press enter to continue



One means to execute this in Python 2, is to usage raw_input():

raw_input("Press Go into to proceed...")In python3 it"s just input()

See more: The Sea Wolf Book Review - The Sea Wolf By Jack London



On my linux box, I use the adhering to code. This is equivalent to code I"ve viewed in other places (in the old python FAQs for instance) but that code spins in a tight loop where this code does not and also tright here are numerous odd corner situations that code doesn"t account for that this code does.

def read_single_keypress(): """Waits for a solitary keypress on stdin. This is a silly feature to call if you must execute it a lot bereason it has to store stdin"s present setup, setup stdin for reading single keystrokes then read the single keystroke then revert stdin earlier after reading the keystroke. Returns a tuple of personalities of the crucial that was pressed - on Linux, pushing secrets prefer up arrowhead results in a sequence of personalities. Returns ("x03",) on KeyboardInterrupt which can take place once a signal gets taken on. """ import termios, fcntl, sys, os fd = sys.stdin.fileno() # conserve old state flags_save = fcntl.fcntl(fd, fcntl.F_GETFL) attrs_conserve = termios.tcgetattr(fd) # make raw - the way to perform this comes from the termios(3) man page. attrs = list(attrs_save) # copy the stored variation to update # iflag attrs<0> &= ~(termios.IGNBRK | termios.BRKINT | termios.PARMRK | termios.ISTRIP | termios.INLCR | termios. IGNCR | termios.ICRNL | termios.IXON ) # oflag attrs<1> &= ~termios.OPOST # cflag attrs<2> &= ~(termios.CSIZE | termios. PARENB) attrs<2> |= termios.CS8 # lflag attrs<3> &= ~(termios.ECHONL | termios.ECHO | termios.ICANON | termios.ISIG | termios.IEXTEN) termios.tcsetattr(fd, termios.TCSANOW, attrs) # turn off non-blocking fcntl.fcntl(fd, fcntl.F_SETFL, flags_save & ~os.O_NONBLOCK) # check out a single keystroke ret = <> try: ret.append( # returns a solitary character fcntl.fcntl(fd, fcntl.F_SETFL, flags_save | os.O_NONBLOCK) c = # returns a solitary character while len(c) > 0: ret.append(c) c = except KeyboardInterrupt: ret.append("x03") finally: # gain back old state termios.tcsetattr(fd, termios.TCSAFLUSH, attrs_save) fcntl.fcntl(fd, fcntl.F_SETFL, flags_save) rerotate tuple(ret)