推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
nekor
V2EX  ›  Python

Python 对 cron 表达式的支持,真的不是很好。

  •  
  •   nekor · Jun 19, 2019 · 3726 views
    This topic created in 2534 days ago, the information mentioned may be changed or developed.

    公司需要使用定时任务,要求必须能输入标准的 cron 表达式,看了很多框架,都不支持标准的 6,7 位 cron 表达式,croniter,crontab,apscheduler 都是只支持 5 位的 cron 表达式。 问问各位大佬,这个需求能否实现?

    6 replies    2019-06-20 16:24:44 +08:00
    jakezh
        1
    jakezh  
       Jun 19, 2019
    需求说一下啊 有什么特殊需求吗
    krixaar
        2
    krixaar  
       Jun 20, 2019
    apscheduler:
    class apscheduler.triggers.cron.CronTrigger(year=None, month=None, day=None, week=None, day_of_week=None, hour=None, minute=None, second=None, start_date=None, end_date=None, timezone=None, jitter=None)

    second minute hour day_of_week day month week year 这还不够用的吗?
    nekor
        3
    nekor  
    OP
       Jun 20, 2019
    @jakezh 很简单,输入‘ 0 15 10 ? * 6L ’这种类型的表达式,获取下次执行的日期时间
    nekor
        4
    nekor  
    OP
       Jun 20, 2019
    @krixaar 需要的是表达式这种形式,例如'0 15 10 ? * 6L'
    Takamine
        5
    Takamine  
       Jun 20, 2019
    要不自己写一个适配器开源出来阿。:doge:
    krixaar
        6
    krixaar  
       Jun 20, 2019
    你都有表达式了,按空格 split 一下填到对应项不就完事了?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1137 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 18:02 · PVG 02:02 · LAX 11:02 · JFK 14:02
    ♥ Do have faith in what you're doing.