请问大佬们,python有没有那种类似于c的kbhit()和getch()类似的函数,就是可以从键盘读取我们摁的按键的函数,最好给个详解谢谢了
import msvcrt
while 1:
if msvcrt.kbhit(): # Key pressed
a = ord(msvcrt.getch()) # get first byte of keyscan code
if a == 0 or a == 224: # is it a function key
b = ord(msvcrt.getch()) # get next byte of key scan code
x = a + (b*256) # cook it.
return x # return cooked scancode
else:
return a # else return ascii code