使用模块

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()  # 启动任务
posted on 2021-06-23 10:32  jaysonteng  阅读(68)  评论(0编辑  收藏  举报