2
我得到以下輸出。這是Pytz的預期行爲嗎?順便說一下,我住在美國/東部時區。爲什麼EST將-04:56作爲時區偏移?pytz和datetime奇怪的行爲 - 可能的錯誤?
import datetime
import pytz
a = datetime.datetime.now()
tz_est = pytz.timezone("US/Eastern")
a = a.replace(tzinfo=tz_est)
print("EST")
print(a)
print("\n")
b = datetime.datetime.now(pytz.timezone("US/Pacific"))
print("PST - version 1")
print(b)
print("\n")
tz_pst = pytz.timezone('US/Pacific')
c = tz_pst.normalize(a)
print("PST - version 2")
print(c)
print("\n")
EST 2017年3月16日22:52:27.616000-04:56
PST - 版本1 2017年3月16日19:52:27.617000-07:00
PST - 版本2 2017年3月16日20:48:27.616000-07:00
[在isoformat時區字段(的可能的複製http://stackoverflow.com/questions/26264897/time-區域中的字段) – DyZ