import sys, msvcrt
print("Please press a key to see its value")
while 1:
key = msvcrt.getch()
print("the key is")
print(key)
if ord(key) == 27: # key nr 27 is escape
sys.exit()
这是我的代码,仅作为示例。该代码在到达key = msvcrt.getch()*, or *key = ord(getch())
时暂停,在这里我使用了第一个。我想让此代码不断打印键是当我提供新的输入时(当我按下一个键时)而不仅仅是打印键是。
所以打印输出看起来像这样:
之类的东西,则不需要每次都想暂停getch的游戏,而您不想让它暂停,等待输入。PYTHON 3.3,msvcrt import sys,msvcrt print(“请按一个键以查看其值”),而1:key = msvcrt.getch()print(“ key is”)print(key)if ord(key) == 27:#键nr 27是...the key is the key is the key is the key is the key is the key is 77 the key is the key is the key is
如果您想制作类似[[snake
msvcrt.kbhit
检查是否已按下键: