解决pythonTimer报错:Exception in thread Thread-1:Traceback most recent call last
最近使用了python的Timer定时器功能,具体用法是:
Timer(interval, function, args=[], kwargs={})
interval: 指定的时间
function: 要执行的方法
args/kwargs: 方法的参数
然后我做了这样的应用:
t=Timer(timer_interval,clearTwoBlock())#定时函数
报错:
Exception in thread Thread-1:
Traceback (most recent call last):
File “D:\Python37\lib\threading.py”, line 917, in _bootstrap_inner
self.run()
File “D:\Python37\lib\threading.py”, line 1158, in run
self.function(*self.args, **self.kwargs)
TypeError: ‘NoneType’ object is not callable
出现该问题的原因是:
Timer的参数中function只写函数名,不要加括号,正确修改为:
t=Timer(timer_interval,clearTwoBlock)#定时函数
其他python相关问题解决办法解决内容见:https://blog.csdn.net/weixin_45386875/article/details/114649392