我试图每 5 秒打印一个句子,我需要向它传递一个参数。
我在用threading
import threading
def printit(whatever):
threading.Timer(5.0, printit).start()
print(whatever)
var= "start"
printit(var)
这给了我这个错误
C:\Users\Wei Xi\Desktop>python test.py
start
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Users\Wei Xi\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Users\Wei Xi\AppData\Local\Programs\Python\Python38\lib\threading.py", line 1254, in run
self.function(*self.args, **self.kwargs)
TypeError: printit() missing 1 required positional argument: 'whatever'```
繁花不似锦
千巷猫影
叮当猫咪
白猪掌柜的
相关分类