我正试图使一个自动点击器控制与键盘 。而我得到
线程-2中出现异常
果然
TypeError: clickc()参数在*后必须是一个可迭代参数,而不是bool。
import keyboard, pyautogui as pag
import time
import threading
number = 9999999999999999999999999999999999999999999999999999999999999999999999999999999
fk = False
def clickc(fk):
if fk == True:
pag.click(button="left", clicks=5, interval=1)
else:
return None
def keycontrol(x, shutdown):
try:
if keyboard.is_pressed(x):
return True
if keyboard.is_pressed(shutdown):
return False
except:
pass
p1 = threading.Thread(target=keycontrol, args=("f","v"))
p0 = threading.Thread(target=clickc, args=fk)
fk = p1.start()
p0.start()
这里是完整的错误。
Exception in thread Thread-2:
Traceback (most recent call last):
File "C:\Users\muham\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Users\muham\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
TypeError: clickc() argument after * must be an iterable, not bool
[Finished in 0.4s]
你的'p0'参数应该是一个可迭代的参数(元组,列表等),就像'p1'一样。
p0 = threading.Thread(target=clickc, args=(fk,))