itoa on python?

Hans Nowak hnowak at
Sun Nov 14 05:19:41 EST 1999

On 14 Nov 99, at 8:52, Gusdvg wrote:

> How can I change an integer (or any other type of number) to a string? In
> C I used itoa but I couldn't find it in the Python documentation.

Try one of these:

x = 42

print str(x)
print `x`
print "%d" % x

The first two work with other types of numbers too. The third one is 
like C's *printf, and is useful if you need formatting and such.

Blessed be,

--Hans Nowak (zephyrfalcon at
You call me a masterless man. You are wrong. I am my own master.

More information about the Python-list mailing list