0

I am converting '12:37:00.60735106' to a time object to get the difference.

 line[1] = '12:37:00.60735106'
 t1 = time.strptime(line[1], "%H:%M:%S.%f")

Error ValueError: unconverted data remains: 06

If I remove the last two digits it works. What am I missing?

When I drop off the last two digits.

line[1] = '12:37:00.607351'
t1 = time.strptime(line[1], "%H:%M:%S.%f")
prints 12:38:00.60734606

Which is longer than my original.

user3525290
  • 1,557
  • 2
  • 20
  • 47
  • 1
    Because `%f` does *micro*seconds, up to 6 decimal places, per [the docs](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior). – jonrsharpe Feb 15 '19 at 11:52
  • So dropping down to only 6 digits is the only way? – user3525290 Feb 15 '19 at 11:54
  • 3
    Possible duplicate of [Parsing datetime strings containing nanoseconds](https://stackoverflow.com/questions/10611328/parsing-datetime-strings-containing-nanoseconds) – Chris Feb 15 '19 at 12:08

0 Answers0