我在Python中有以下字符串 - 'Oct 01 2013 07 30 PM EST'。我试图转换为日期时间对象,但出现以下错误:Python字符串到日期时间的麻烦
ValueError: time data 'Oct 01 2013 07 30 PM EST' does not match format
'%b %d %Y %I %M %p %Z'
不知道我要去哪里错了!请帮忙。我的代码如下:
from datetime import datetime
date_object = datetime.strptime(str(date), '%b %d %Y %I %M %p %Z')
的原因是时区。请检查这个问题http://stackoverflow.com/questions/1703546/parsing-date-time-string-with-timezone-abbreviated-name-in-python – oleg
啊,谢谢!我刚刚删除了时区,现在它可以正常工作。 – sewardth