Python summing up time

It depends on the form you have these times in, for example if you already have them as datetime.timedeltas, then you could just sum them up:

>>> s = datetime.timedelta(seconds=0) + datetime.timedelta(seconds=15) + datetime.timedelta(hours=9, minutes=30, seconds=56)
>>> str(s)
'9:31:11'

Leave a Comment