#!/user/bin/python3
# -*- 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))
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)