不难理解,实例化的时候两个参数:时间间隔(延迟多久执行),函数名(需执行的函数名)
from threading import Timer
def demo():
print('hello world!')
timer = Timer(2, demo)
timer.start()
执行结果: 两秒后打印出 hello world
不难理解,实例化的时候两个参数:时间间隔(延迟多久执行),函数名(需执行的函数名)
from threading import Timer
def demo():
print('hello world!')
timer = Timer(2, demo)
timer.start()
执行结果: 两秒后打印出 hello world