Python APScheduler打印时间

Python APScheduler打印时间,python,datetime,apscheduler,Python,Datetime,Apscheduler,嗨,我想继续我的工作。我找到了另一个问题的解决方案。然而,我仍然想找到解决这个问题的办法。有没有办法从ApsScheduler打印时间 我用过: from apscheduler.schedulers.background import BackgroundScheduler from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor sched = BackgroundScheduler(tim

嗨,我想继续我的工作。我找到了另一个问题的解决方案。然而,我仍然想找到解决这个问题的办法。有没有办法从ApsScheduler打印时间

我用过:

from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor

sched = BackgroundScheduler(timezone='America/Toronto', executors=executors)
从那里我想机器可以从它的时区知道时间。我只需要把它打印出来。当然,一个解决方案可以是导入

import pytz
toronto = pytz.timezone('America/Toronto')

从那个时区获取时间。但是,它是重复的,像是吗?那么,有没有一种方法可以单独使用APScheduler来实现这一点呢?

你的意思是像
sched.timezone
?并打印当前时间。如何从
pytz.timezone('America/Toronto')
获取时间,因为这应该适用于
sched.timezone
?一种简单的方法是
importdatetime;datetime.datetime.now(sched.timezone)
Ohh等等,让我试试它是如何工作的!您应该将其作为解决方案发布。