[Tutor] print question

John Fouhy john at fouhy.net
Tue Oct 9 03:24:40 CEST 2007


On 09/10/2007, Dick Moores <rdm at rcblue.com> wrote:
> What's the best way to get hours in 2 or more digits, and minutes in
> 2 digits, so that the above would be 05:07:36.88? (I'm writing a stopwatch.)

String formatting!

>>> template = '%02d:%02d:%02d.%02d'
>>> template % (1, 22, 3, 44)
'01:22:03.44'

-- 
John.


More information about the Tutor mailing list