首页 > 编程语言 > 详细

python定时任务

时间:2021-06-23 15:35:42      阅读:21      评论:0      收藏:0      [点我收藏+]

使用模块

apscheduler

代码

import time
from apscheduler.schedulers.blocking import BlockingScheduler

def func(a, b):  # 定时执行的函数
    print(a, b)

if __name__ == ‘__main__‘:
    sched = BlockingScheduler()
    sched.add_job(func,  # 定时执行的函数
                  ‘cron‘, 
                  hour=7, minute=0, second=0,  # 每天执行的时分秒
                  coalesce=True, 
                  args=[a, b]  # 函数参数
                 )
    sched.start()  # 启动任务

python定时任务

原文:https://www.cnblogs.com/jaysonteng/p/14921650.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!