formatting a number as percentage

Günther Dietrich gd_usenet at spamfence.net
Sun Feb 21 13:18:05 EST 2010


vsoler <vicente.soler at gmail.com> wrote:

>I'm trying to print .7 as 70%
>I've tried:
>
>print format(.7,'%%')
>.7.format('%%')
>
>but neither works. I don't know what the syntax is...

Did you try this:

>>> print('%d%%' % (0.7 * 100))
70%



Best regards,

Günther



More information about the Python-list mailing list