Formatting Time

rochoa at cimex.com.cu rochoa at cimex.com.cu
Thu Jun 2 19:30:41 EDT 2005


May be

>>> sec = 2472
>>> "%d:%02d:%02d" % (int(sec/360), int(sec % 360 /60), int(sec % 60))
'6:05:12'

Regards

-----Mensaje original-----
De: Ognjen Bezanov [mailto:ognjen at mailshack.com] 
Enviado el: Jueves, 02 de Junio de 2005 03:29 p.m.
Para: python-list at python.org
Asunto: Formatting Time

I never thought id need help with such a thing as time formatting
(admittadly i never did it before) but ok, i guess there is a first for
everything.

I have a float variable representing seconds, and i want to format it
like this:

0:00:00  (h:mm:ss)

Now search as I might i am finding this quite elusive, i had a look at
the time module but that seems overly complicated for this. Anyone got
any simple solutions to doing this? cheers!






More information about the Python-list mailing list