I have the following code:
from datetime import datetime
date_time_str = '2020-07-17 21:59:49.55'
date_time_obj = datetime.strptime(date_time_str, '%y-%m-%d %H:%M:%S.%f')
print "The type of the date is now", type(date_time_obj)
print "The date is", date_time_obj
Which results in the err:
Traceback (most recent call last):
File "main.py", line 5, in <module>
date_time_obj = datetime.strptime(date_time_str, '%y-%m-%d %H:%M:%S.%f')
File "/usr/lib/python2.7/_strptime.py", line 332, in _strptime
(data_string, format))
ValueError: time data '2020-07-17 21:59:49.553' does not match format '%y-%m-%d %H:%M:%S.%f'
Why cant I convert this date? The following example works:
date_time_str = '18/09/19 01:55:19'
date_time_obj = datetime.strptime(date_time_str, '%d/%m/%y %H:%M:%S')