doupoa
一个不甘落后的热血青年!
Ping通途说

[PytzUsageWarning]消除使用apscheduler时遇到的警告

C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\apscheduler\util.py:95: PytzUsageWarning: The zone attribute is specific to pytz's interface; please migrate to a new time zone provider. For more details on how to do so, see https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html
  if obj.zone == 'local':

很明显这是一个警告,而警告的来源是apscheduler产生的。

若要消除这个警告,我们可以:

1.在装饰器上

@scheduler.scheduled_job("cron", minute="*/1", id="xxx", timezone='Asia/Shanghai')
async def do_something():
    pass

即添加一个“timezone”

2.在 add_job 上

from apscheduler.schedulers.background import BackgroundScheduler

sched = BackgroundScheduler(timezone='Asia/Shanghai')

3.运行一下,问题解决

赞赏
没有标签
首页      关于这里      [PytzUsageWarning]消除使用apscheduler时遇到的警告

doupoa

文章作者

诶嘿

发表回复

textsms
account_circle
email

Ping通途说

[PytzUsageWarning]消除使用apscheduler时遇到的警告
C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\apscheduler\util.py:95: PytzUsageWarning: The zone attribute is specific to pytz's interface;…
扫描二维码继续阅读
2022-05-02

Optimized by WPJAM Basic