|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
from datetime import datetime
from datetime import date
from apscheduler.schedulers.blocking import BlockingScheduler
def job(text):
print(text)
scheduler = BlockingScheduler()
# 在 2019-8-30 运行一次 job 方法
scheduler.add_job(job, 'date', run_date=date(2019, 8, 30), args=['text1'])
# 在 2019-8-30 01:00:00 运行一次 job 方法
scheduler.add_job(job, 'date', run_date=datetime(2019, 8, 30, 1, 0, 0), args=['text2'])
# 在 2019-8-30 01:00:01 运行一次 job 方法
scheduler.add_job(job, 'date', run_date='2019-8-30 01:00:00', args=['text3'])
scheduler.start()
---------------------------------------------------------------
D:\python3.8\python.exe C:/Users/000/Desktop/python/jd/.idea/a.py
Traceback (most recent call last):
File "C:/Users/000/Desktop/python/jd/.idea/a.py", line 8, in <module>
scheduler = BlockingScheduler()
File "D:\python3.8\lib\site-packages\apscheduler\schedulers\base.py", line 87, in __init__
self.configure(gconfig, **options)
File "D:\python3.8\lib\site-packages\apscheduler\schedulers\base.py", line 126, in configure
self._configure(config)
File "D:\python3.8\lib\site-packages\apscheduler\schedulers\base.py", line 697, in _configure
self.timezone = astimezone(config.pop('timezone', None)) or get_localzone()
File "D:\python3.8\lib\site-packages\tzlocal\win32.py", line 93, in get_localzone
_cache_tz = pytz.timezone(get_localzone_name())
File "D:\python3.8\lib\site-packages\tzlocal\win32.py", line 84, in get_localzone_name
raise pytz.UnknownTimeZoneError('Can not find timezone ' + tzkeyname)
pytz.exceptions.UnknownTimeZoneError: 'Can not find timezone '
|
|