python定时器,该怎么解决

python定时器
每个一定时间,就执行一次操作

------解决方案--------------------
临时写了个,可用返回来的函数控制停止操作。
from threading import Timer
def executeEvery(seconds,callback):
    def f():
        callback()
        t = Timer(seconds,f)
        t.start()
    def stop():
        t.cancel()
        
    t = Timer(seconds,f)
    t.start()
    
    return stop    
        
def printHello():
    print('hello')
    
executeEvery(2,printHello)