def strfdelta(tdelta, fmt):
d = {"days": tdelta.days}
d["hours"], rem = divmod(tdelta.seconds, 3600)
d["minutes"], d["seconds"] = divmod(rem, 60)
return fmt.format(**d)
from datetime import timedelta
timedelta_object = timedelta(hours=24.5)
print(str(timedelta_object)) # '1 day, 0:30:00'