我有一个继续监听的函数。我想在特定时间后停止监听器
import time
from pynput.keyboard import Listener
with Listner(on_press=onPress) as l:
l.join
这是一个无休止的循环...我想在特定时间后停止监听器
答案 0 :(得分:1)
您可以使用timer:
from threading import Timer
from pynput.keyboard import Listener
def on_press(key):
print(key)
with Listener(on_press=on_press) as l:
Timer(5, l.stop).start()
l.join()
print('5 seconds passed')
答案 1 :(得分:0)
<input type="file" id="filetag">
<img src="" id="preview">