FreeThreads
Published in

FreeThreads

Python datetime strptime: unconverted data remains

Problem

timeobj = datetime.datetime.strptime(my_time, '%Y-%m-%d %H:%M:%S').isoformat()
File "/usr/lib/python2.7/_strptime.py", line 335, in _strptime
data_string[found.end():])
ValueError: unconverted data remains:

Solution

The error was an elusive one. The solution was to make sure that the input time string is exactly as the format expected.
The missing piece was an extra space after the string which was causing a format mismatch.
So the solution was to call strip() on the…

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Simplify Complexity

Simplify Complexity

Golang, Distributed Systems, File Systems, Python, C/C++, Linux