在python中使用sched模块实现周期性执行函数,具体方法如下:
import time,sched,os #初始化sched模块的scheduler类
s = sched.scheduler(time.time,time.sleep)
def event_func():
print "Current Time:",time.time()
def perform(inc):
s.enter(inc,0,perform,(inc,))
event_func()
def mymain(inc=60):
s.enter(0,0,perform,(inc,))
s.run()