pyhton的定时任务写法:
#!/usr/bin/env python
#-- encoding:utf-8 --
import time
def task():
print "task ..."
def timer(n):
while True:
print time.strftime('%Y-%m-%d %X',time.localtime())
task()
time.sleep(n)
if __name__ == '__main__':
timer(5)
本文介绍了一个简单的Python定时任务实现方案,通过无限循环结合time模块来定期执行指定的任务。
1297

被折叠的 条评论
为什么被折叠?



