python - 具有不同时区的 APScheduler

标签 python timezone apscheduler

我在程序中使用 APScheduler 在特定日期时间安排作业。但是,我正在处理与本地时间不同时区的日期时间。所以我传递给 APScheduler 的日期时间始终是一个时区感知的日期时间...

sched.add_date_job(my_job, exec_date, ['text'])

我总是得到:无法比较偏移天真和偏移感知的日期时间 来自 APScheduler...

请帮忙...

最佳答案

使用新版本的 APScheduler (3.4.0),您可以按如下方式设置时区:

UTC 时区实例化 APScheduler

from apscheduler.schedulers.background import BackgroundScheduler
scheduler = BackgroundScheduler({'apscheduler.timezone': 'UTC'})

欧洲/伦敦时区实例化 APScheduler

from apscheduler.schedulers.background import BackgroundScheduler
scheduler = BackgroundScheduler({'apscheduler.timezone': 'Europe/London'})

来源:http://apscheduler.readthedocs.io/en/latest/userguide.html#configuring-the-scheduler

关于python - 具有不同时区的 APScheduler,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22891040/

相关文章:

python - 用python识别文本布局

python - Groovy 脚本无法执行外部进程

用于转换为任何本地时间的 c++ 库(由 linux zoneinfo 字符串定义)

timezone - ubuntu : change timezone to UTC does not affect the time of syslog?

python - APScheduler 会跳过作业并在其他时间运行

python - 如何将 POST 参数解析为 REST 服务?

python - 什么是西格玛裁剪?你怎么知道什么时候应用它?

java - 如何解析包含区域设置的日期字符串

python - Flask APScheduler - Cron Job 只发生在页面上的活跃用户身上

python - APScheduler 执行后立即退出