我試圖使用strptime將日期和時間字符串(如「2016年3月15日10:47:15」)轉換爲Python日期時間對象。我相信我有這個格式正確,但是我仍然獲得了ValueError異常,當我運行如下:在Python中將可讀的日期和時間字符串轉換爲日期時間對象
>>> s = "Mar 15, 2016 10:47:15"
>>> datetime.datetime.strptime(s,"%b %m, %Y %H:%M:%S")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/_strptime.py", line 325, in _strptime
(data_string, format))
ValueError: time data 'Mar 15, 2016 10:47:15' does not match format '%b %m, %Y %H:%M:%S'
任何想法,什麼可能是錯了我的格式字符串?
呃,不敢相信我錯過了!乾杯 –