【发布时间】:2018-04-27 20:04:19
【问题描述】:
我正在编写一个简单的 python 代码,它应该检测我的击键,但由于某种原因在每次击键后检测空间。
代码:
import msvcrt
print("press 'escape' to quit...")
text=""
while 1:
char = msvcrt.getch()
print(ord(char))
示例运行:
Input: aaaaa
Output:
97
0
97
0
97
0
97
0
97
0
【问题讨论】:
-
那么问题出在哪里?你的代码打印是什么?
标签: python windows python-3.x msvcrt getch