here
,关于标记的夏令时小时数@马特梅塞斯密斯和蔼而熟练地回答了我的问题和他的解决办法
在Linux中运行良好
(Ubuntu版),
但不是在我的任何一台Windows机器上
(工作和家庭)。
在Windows上运行代码时,出现以下错误:
Traceback (most recent call last):
File "<ipython-input-185-ed30519c4311>", line 1, in <module>
transition_times = [t.astimezone(tz) for t in transition_times]
File "<ipython-input-185-ed30519c4311>", line 1, in <listcomp>
transition_times = [t.astimezone(tz) for t in transition_times]
OSError: [Errno 22] Invalid argument
以下是在我的Windows计算机上产生错误的代码:
from pytz import timezone
# Map transition times to year for some efficiency gain
tz = timezone('America/Denver')
transition_times = tz._utc_transition_times[1:]
transition_times = [t.astimezone(tz) for t in transition_times]