import time
import schedule # cd C:Python36-32Scripts 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)