我正在尝试在while循环中运行一个线程,但是出现了错误 RuntimeError: threads can only be started once
请建议一种修复方法。
import sys
import threading
import time
import keyboard
def hd():
time.sleep(1)
print("hello")
cc = threading.Thread(target=hd)
while True:
time.sleep(3)
if keyboard.is_pressed("q"):
print("Q is pressed")
sys.exit()
else:
if not cc.is_alive():
cc.start()
hd()
,直到键盘上按下Q
键? - Kris