解析ISO日期时间在Python
问题描述:
可能重复:
Converting string to datetime object in python解析ISO日期时间在Python
鉴于以下的Python
import datetime
>>> a
'2011-05-04 16:20:09 -0700'
>>> datetime.datetime.strptime(a, "%Y-%m-%d %H:%M:%S %z")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/_strptime.py", line 317, in _strptime
(bad_directive, format))
ValueError: 'z' is a bad directive in format '%Y-%m-%d %H:%M:%S %z'
>>>
我真的不知道如何%z
是一个糟糕的指令。
参考: http://docs.python.org/library/datetime.html#strftime-strptime-behavior
这是汞,它说,它是在ISO8601的格式。
相关:http://*.com/questions/526406/python-time-to-年龄部分2时区 – jathanism 2011-05-05 18:38:05
@前哨:谢谢。 – 2011-05-05 18:44:01