The function below converts a time code into seconds, while maintaining the decimal value (fractions of seconds). The time code fed to this function will always contain microseconds. This currently works, but I'd be interested to see how it could be improved/simplified.
def Second_Conversion(x): #Takes a string such as "2:22:04.996304" HMS = x.split(':') SF = x.split('.') Full_HMS = x[0:7] Split_HMS = Full_HMS.split(':') Full_Units = int(Split_HMS) * 3600 + int(Split_HMS) * 60 + int(Split_HMS) Second_Fractions = int(SF) Converted_Seconds_Fractions = Second_Fractions /1000000 print(Converted_Seconds_Fractions) Final_Time = Full_Units + Converted_Seconds_Fractions print(Final_Time)