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

相关文章:

  • 2022-12-23
  • 2021-06-29
  • 2021-08-21
  • 2021-11-26
  • 2022-12-23
  • 2021-05-31
猜你喜欢
  • 2022-12-23
  • 2021-06-18
  • 2021-08-16
  • 2022-01-27
  • 2022-12-23
  • 2021-09-18
  • 2021-10-25
相关资源
相似解决方案