float print formatting

Grant Edwards grante at visi.com
Tue Feb 13 10:40:54 EST 2007


On 2007-02-13, hg <hg at nospam.org> wrote:
> Hi,
>
> Considering the float 0.0, I would like to print 00.00.
>
> I tried '%02.02f' % 0.0 ... but I get 0.00
            ^^
That's the specifierfor how many total columns you want to use
(including the decimal point and all digits to either side).

> Any clue ?

>>> "%05.02f" % 0.0
'00.00'

-- 
Grant Edwards                   grante             Yow!  Yow!! "Janitor
                                  at               trapped in sewer uses ESP
                               visi.com            to find decayed burger"!!



More information about the Python-list mailing list