a=0100; print a ; 64 how to reverse this?

Neil Cerutti horpner at yahoo.com
Tue Jul 17 09:47:17 EDT 2007


On 2007-07-17, mosi <skawanagi at gmail.com> wrote:
> Thank you,
> this is great,
> I thought that this should be standard in python 2.4 or 2.5 or in some
> standard library (math ???)
> Didn`t find anything.

Support is built-in for string representations of numbers in other
than base 10, but conversions to integer is the only support.

You can do:

>>> d = int(s, base).

but not:

>>> s = str(d, base)

The % format operator can do hex and octal, I believe.

-- 
Neil Cerutti



More information about the Python-list mailing list