On Thu, May 26, 2016 at 12:16 AM, Steven D'Aprano
<steve+comp.lang.pyt...@pearwood.info> wrote:
> I have a timedelta object, and I want to display it in a nice human-readable
> format like 03:45:17 for "three hours, forty five minutes, 17 seconds".
>
> Is there a standard way to do this?

   >>> timedelta(100)
   datetime.timedelta(100)
   >>> str(timedelta(seconds=100))
   '0:01:40'
   >>> str(timedelta(hours=100))
   '4 days, 4:00:00'

(I recently spent *way* too long trying to figure out how to properly
format the thing before being reminded that a plain str call gives
exactly what I was after.)

-- 
Zach
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to