Python3 schedule定时任务

import time
import schedule  # cd C:\Python36-32\Scripts  pip install schedule
# py文件名字不能叫schedule,否则会报module 'schedule' has no attribute 'every'

def hello(name): print("hello %s" % name)
def job1(): print("job1")
# 定时任务 schedule.every(5).seconds.do(hello, 'zs') #每5秒 schedule.every(5).seconds.do(job1) # schedule.every().minutes.do(job, name) # schedule.every().hour.do(job, name) # schedule.every().day.at("10:30").do(job, name) # schedule.every(5).to(10).days.do(job, name) # schedule.every().monday.do(job, name)
while True: schedule.run_pending() time.sleep(1)
posted @ 2019-04-15 10:29  大飞90  阅读(2023)  评论(0编辑  收藏  举报