티스토리 뷰

728x90
def get_sec(time_str):
    """Get seconds from time."""
    h, m, s = time_str.split(':')
    return int(h) * 3600 + int(m) * 60 + int(s)


print(get_sec('1:23:45'))
print(get_sec('0:04:15'))
print(get_sec('0:00:25'))

https://stackoverflow.com/questions/6402812/how-to-convert-an-hmmss-time-string-to-seconds-in-python

 

How to convert an H:MM:SS time string to seconds in Python?

Basically I have the inverse of this problem: Python Time Seconds to h:m:s I have a string in the format H:MM:SS (always 2 digits for minutes and seconds), and I need the integer number of seconds...

stackoverflow.com

 

728x90
댓글
댓글쓰기 폼