If you are repran datetime.timeobject, Python gives you isoformat. Since reprtrying to be serialized versions of its objects, this is a good indication of what value you should use.
import datetime
timestring = datetime.datetime.now().time().isoformat()
timeobj = datetime.datetime.strptime(timestring, "%H:%M:%S.%f").time()
source
share