I need to convert time value strings given in the following format to seconds, for example:
1.\'00:00:00,000\' -> 0 seconds 2.\'00:00:10,000\' -> 10 s
def time_to_sec(time): sep = ',' rest = time.split(sep, 1)[0] splitted = rest.split(":") emel = len(splitted) - 1 i = 0 summa = 0 for numb in splitted: szor = 60 ** (emel - i) i += 1 summa += int(numb) * szor return summa