def wait(hotkey=None, suppress=False, trigger_on_release=False):
"""
Blocks the program execution until the given hotkey is pressed or,
if given no parameters, blocks forever.
"""
if hotkey:
lock = _Event()
remove = add_hotkey(hotkey, lambda: lock.set(), suppress=suppress, trigger_on_release=trigger_on_release)
lock.wait()
remove_hotkey(remove)
else:
while True:
_time.sleep(1e6)
题主你好,刚去看了下源码。你这个keyboard.wait()使用错了。wait()这个方法没有按键盘的hotkey的话,wait()是一直阻塞的。所以你不能直接print keyboard.wait()。你上面写那个函数,把一直阻塞的wait() print出来,因为wait()一直在阻塞,你print的时候,实际执行的是print(wait()方法else后面的语句),所以会造成溢出错误。下面是wait()源码,供你参考。