#!/user/bin/python3标签:sched,python,datetime,cron,frequency,croniter,表达式 From: https://www.cnblogs.com/zhaoruixiao/p/17027533.html
# -*- coding:utf-8 -*-
# @Author: zhaoruixiao
# @Datetime: 2023/1/5 14:30
# @Software: PyCharm
# @File : cron.py
"""
work for $ 用python得知 cron表达式
"""
import croniter, datetime
def CronRunNextTimelist(sched, frequency=1):
now = datetime.datetime.now()
cron = croniter.croniter(sched, now)
return [cron.get_next(datetime.datetime).strftime("%Y-%m-%d %H:%M") for i in range(frequency)]
sched = "0 0 8 * *"
print(CronRunNextTimelist(sched, frequency=2))