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)

转载于:https://www.cnblogs.com/songfei90/p/10709203.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值