我有一个约会:
from datetime import datetime
from datetime import tzinfo
test = '2013-03-27 23:05'
test2 = datetime.strptime(test,'%Y-%m-%d %H:%M')
>>> test2
datetime.datetime(2013, 3, 27, 23, 5)
>>> test2.replace(tzinfo=EST)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'EST' is not defined
>> test2.replace(tzinfo=UTC)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'UTC' is not defined
Run Code Online (Sandbox Code Playgroud)
我找不到names可以在replace.tzinfo=调用中分配给tzinfo 的时区列表中的文档.
我已阅读以下内容,但没有任何内容:
http://docs.python.org/2/library/datetime.html#tzinfo-objects
我也在谷歌搜索过.
编辑:我按照unutbu提供的解决方案,但我得到以下内容:
>>> test = '2013-03-27 00:05'
>>> test …Run Code Online (Sandbox Code Playgroud)