Timer: 隔一定时间调用一个函数,如果想实现每隔一段时间就调用一个函数的话,就要在Timer调用的函数中,再次设置Timer。Timer是Thread的一个派生类
from threading import Timer import time def task(): print('线程执行了') time.sleep(2) print('线程结束了') t=Timer(4,task) t.start()