Decimal formatting

Aahz aahz at pythoncraft.com
Thu Sep 13 23:51:00 EDT 2007


In article <1189717147.538624.189890 at 19g2000hsx.googlegroups.com>,
mensanator at aol.com <mensanator at aol.com> wrote:
>
>>>> a
>12.33333
>>>> print '%0.2f' % a
>12.33
>>>> a = 1
>>>> print '%0.2f' % a
>1.00

>>> '%.2f' % 1
'1.00'
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Many customs in this life persist because they ease friction and promote
productivity as a result of universal agreement, and whether they are
precisely the optimal choices is much less important." --Henry Spencer
http://www.lysator.liu.se/c/ten-commandments.html



More information about the Python-list mailing list