在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()