文章目录[隐藏]
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')
发表回复