Seconds ==> HH:MM:SS
sec = 6010# 方法1from datetime import timedeltatd = timedelta(seconds=sec)str(td)# 方法2hours = sec // 3600 % 24minutes = sec // 60 % 60seconds = sec % 60td = f'{hours}:{minutes}:{seconds}'
HH:MM:SS ==> Seconds
td = '1:40:10'# 方法1hours, minutes, seconds = map(int, td.split(':'))sec = hours * 3600 + minutes * 60 + seconds# 方法2sec = timedelta(hours=hours, minutes=minutes, seconds=seconds).seconds
