String To Time With Decimal Seconds
Say I have a string with format HHMMSS.SS how do I convert this to a time object? This is how I thought you would do it: import time time.strptime(timestring, '%H%M%S') However%S
Solution 1:
You will have to use %f
time.strptime('26/01/12 23:50:32.123', '%d/%m/%y %H:%M:%S.%f')
Use of datetime will be right
>>>from datetime import datetime>>>a = datetime.strptime('26/01/12 23:50:32.123', '%d/%m/%y %H:%M:%S.%f')>>>a.microsecond
Post a Comment for "String To Time With Decimal Seconds"