-2
istanbul = timezone('Europe/Istanbul')
created_at = "Wed Aug 29 17:12:58 +0000 2012"
dtt = created_at.replace(tzinfo=istanbul)
xnxx = time.mktime(time.strptime(str(dtt),"%Y-%m-%d %H:%M:%S"))

错误:未转换的数据仍然存在:+01:57

4

1 回答 1

2

看看pytz 文档。实际上只有一种方法可以更改时区。您必须使用localizeastimezone

from datetime import datetime
import pytz
istanbul = pytz.timezone('Europe/Istanbul')
created_at = datetime.strptime("Wed Aug 29 17:12:58 +0000 2012", 
                               "%a %b %d %H:%M:%S %z %y")
pytz.utc.localize(created_at).astimezone(istanbul)
于 2013-09-06T01:41:03.753 回答