#!/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))
posted on 2023-01-05 14:49  aha_baby  阅读(418)  评论(0编辑  收藏  举报