itoa

Michael Hudson mwh21 at cam.ac.uk
Mon Mar 13 19:57:43 EST 2000


m.faassen at vet.uu.nl (Martijn Faassen) writes:

> Stuart Reynolds <S.I.Reynolds at cs.bham.ac.uk> wrote:
> > Is there an integer to ascii (itoa) function in Python? I need to
> > convert integers into various different bases (but to binary, in
> > particular). Most languages come provided with an itoa-like function but
> > I can't seem to find one in the Python API.
> 
> Replying again -- I'm reading the standard library and you might find
> the string.atoi() function useful if you're converting to different
> bases and such:
> 
> >>> string.atoi("11", 2)
> 3
> 

>>> int("23",4)
11

This is with a cvs python, but I think the change went in between 1.5
and 1.5.1.

Cheers,
M.

-- 
very few people approach me in real life and insist on proving they are
drooling idiots.                         -- Erik Naggum, comp.lang.lisp



More information about the Python-list mailing list