python定时任务

#!/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)

 

posted on 2015-12-17 22:09  Arvin-9  阅读(164)  评论(0编辑  收藏  举报

导航