Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- time = "01:30" # 1 minute and 30 seconds
- time2 = time + 10 seconds
- def format_duration(seconds):
- minutes, seconds = divmod(seconds, 60)
- hours, minutes = divmod(minutes, 60)
- return '{:02d}:{:02d}:{:02d}'.format(hours, minutes, seconds)
- >>> def format_duration(seconds):
- ... minutes, seconds = divmod(seconds, 60)
- ... hours, minutes = divmod(minutes, 60)
- ... return '{:02d}:{:02d}:{:02d}'.format(hours, minutes, seconds)
- ...
- >>> duration = 170
- >>> format_duration(duration)
- '00:02:50'
- >>> duration += 10
- >>> format_duration(duration)
- '00:03:00'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement