float print formatting

Peter Otten __peter__ at web.de
Tue Feb 13 09:20:18 EST 2007


hg wrote:

> Considering the float 0.0, I would like to print 00.00.
> 
> I tried '%02.02f' % 0.0 ... but I get 0.00
> 
> Any clue ?

The first integer specifies the total width:

>>> "%05.2f" % 0
'00.00'

Peter



More information about the Python-list mailing list