解决pythonTimer报错:Exception in thread Thread-1:Traceback most recent call last
Recently used the timer function of python, the specific usage is:
Timer(interval, function, args=[], kwargs={
})
interval: the specified time
function: the method to be executed
args/kwargs: the parameters of the method
Then I made an application like this:
t=Timer(timer_interval,clearTwoBlock())#定时函数
Error:
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
The reasons for this problem are:
In the Timer parameter, only write the function name in function, do not add parentheses, and correct it to:
t=Timer(timer_interval,clearTwoBlock)#定时函数