如何在datetime.strptime中添加时区
来源:http://tieba.baidu.com/p/3367509493
time_1 = datetime.datetime.now(pytz.timezone(*Asia/Shanghai*))
time_2 = datetime.datetime.strptime(*2014-10-23 12:00:00*, "%Y-%m-%d %H:%M:%S")
time_1生成的是包含时区的offset-aware型的datetime,
time_2好像是不包含时区信息的offset_naive型的datetime。
time_1 = datetime.datetime.strptime("2014-10-1 12:00:00", "%Y-%m-%d %H:%M:%S")
如此得到的time_1是offset-naive类型的datetime,
time_1 = time_1.replace(tzinfo=pytz.timezone(*Asia/Shanghai*))
如此即可转换为offset-aware类型的datetime