python 监听键盘输入
作者:互联网
import sys, select, tty, termios old_attr = termios.tcgetattr(sys.stdin) tty.setcbreak(sys.stdin.fileno()) print('Please input keys, press Ctrl + C to quit') while(1): if select.select([sys.stdin], [], [], 0)[0] == [sys.stdin]: print(sys.stdin.read(1)) termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_attr)
参考: https://blog.csdn.net/NiYintang/article/details/86116591
标签:tty,old,python,stdin,termios,sys,键盘输入,监听,select 来源: https://www.cnblogs.com/sea-stream/p/11210288.html