Coding = utf-8 #
# From: Python-CN Group: http://groups.google.com/group/python-cn/browse_thread/thread/bb729a571cd3b091
# Q: # raw_input input will be needed to complete the transport input There is no need to enter a carriage return can input methods.
#
# A: (by Leo Jay)
# You do not say what platform you are, you want exhausted me :)
on # windows platform is very simple, msvcrt library has a direct function getch can handle.
The # linux on the tired, use the termios module, modify the properties of the terminal is non-canonical mode, giving you a look at some code to
Import SYS
Import termios
fd = SYS . stdin . fileno () old = termios . tcgetattr ( fd ) new = termios . tcgetattr ( fd ) new [ 3 ] = new [ 3 ] & ~ termios . ICANON TRY: termios . tcsetattr ( fd , termios . TCSADRAIN , new ) while True : input = SYS . stdin . Read ( 1 ) Print 'get' , input if input == 'q' :break finally : termios . tcsetattr ( fd , termios . TCSADRAIN , old )
# From: Python-CN Group: http://groups.google.com/group/python-cn/browse_thread/thread/bb729a571cd3b091
# Q: # raw_input input will be needed to complete the transport input There is no need to enter a carriage return can input methods.
#
# A: (by Leo Jay)
# You do not say what platform you are, you want exhausted me :)
on # windows platform is very simple, msvcrt library has a direct function getch can handle.
The # linux on the tired, use the termios module, modify the properties of the terminal is non-canonical mode, giving you a look at some code to
Import SYS
Import termios
fd = SYS . stdin . fileno () old = termios . tcgetattr ( fd ) new = termios . tcgetattr ( fd ) new [ 3 ] = new [ 3 ] & ~ termios . ICANON TRY: termios . tcsetattr ( fd , termios . TCSADRAIN , new ) while True : input = SYS . stdin . Read ( 1 ) Print 'get' , input if input == 'q' :break finally : termios . tcsetattr ( fd , termios . TCSADRAIN , old )