[Tutor] int to string

Andreas Kostyrka andreas at kostyrka.org
Sat Mar 22 09:49:02 CET 2008


Beside casting it with str(), you can also use a format string:

assert "%d" % 10 == "10"
assert "%5d" % 10 == "   10"
assert "%05d" % 10 == "00010"

In practice % supports a superset of what printf in C provides.

Andreas

Am Freitag, den 21.03.2008, 17:05 -0700 schrieb elis aeris:
> how do I convert int to string?
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://mail.python.org/pipermail/tutor/attachments/20080322/005a0d90/attachment.pgp 


More information about the Tutor mailing list