-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'
有人可以帮助我在哪里,我在做什么错误。在此先感谢