python日期时间格式不正确
我得到一个python异常,我的字符串日期时间不匹配,但我看不出有什么问题python日期时间格式不正确,python,python-2.7,parsing,datetime,Python,Python 2.7,Parsing,Datetime,我得到一个python异常,我的字符串日期时间不匹配,但我看不出有什么问题 ValueError: time data '2017-08-25T02:19:53.000' does not match format '%Y-%m-%dT%H:%M:%S.%fZ' 2017-08-25T02:19:53.000不匹配,因为它没有Zulu(Z)结尾 相反,格式应为%Y-%m-%dT%H:%m:%S.%f 从ipython: In [1]: from datetime import datetime
ValueError: time data '2017-08-25T02:19:53.000' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'
2017-08-25T02:19:53.000
不匹配,因为它没有Zulu(Z
)结尾
相反,格式应为%Y-%m-%dT%H:%m:%S.%f
从ipython
:
In [1]: from datetime import datetime
In [2]: do = datetime.strptime('2017-08-25T02:19:53.000', '%Y-%m-%dT%H:%M:%S.%f')
In [3]: do
Out[3]: datetime.datetime(2017, 8, 25, 2, 19, 53)