-1
我有一個包含日期的字符串,我試圖使用strptime()匹配日期格式,但拋出以下錯誤。ValueError:時間數據'abc-xyz-listener.log.2016-10-18-180001'與格式不匹配'%Y-%m-%d'
import datetime
datetime.datetime.strptime("abc-xyz-listener.log.2016-10-18-180001", "%Y-%m-%d")
我得到以下幾點:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
datetime.datetime.strptime("abc-xyz-listener.log.2016-10-18-180001", "%Y-%m-%d")
File "C:\Python27\lib\_strptime.py", line 325, in _strptime
(data_string, format))
ValueError: time data 'abc-xyz-listener.log.2016-10-18-180001' does not match format '%Y-%m-%d'
有人可以幫助我在哪裏,我在做什麼錯誤。在此先感謝