How to covert ASCII to integer in Python?

Mensanator mensanator at aol.com
Fri May 30 11:41:16 EDT 2008


On May 30, 10:03�am, Philipp Pagel <pDOTpa... at helmholtz-muenchen.de>
wrote:
> Skonieczny, Chris <Skonieczn... at emssatcom.com> wrote:
> > YOU SHOULD REMOVE or CORRECT YOUR POST here:
> >http://mail.python.org/pipermail/python-list/2007-February/427841.html�
>
> > It is not true - eg. try :
> > a='P' � � � � � �# P is ASCII , isn't it ?
> > b=int(a)
> > and what you will get ? An error !!!
>
> 'P' is obviously not an ASCII representation of a number.

It is in base 36.

>>> a='P'
>>> b=int(a,36)
>>> b
25


> What did you expect? The closest number by visual appearance?
>
> cu
> � � � � Philipp
>
> --
> Dr. Philipp Pagel
> Lehrstuhl f. Genomorientierte Bioinformatik
> Technische Universit�t M�nchenhttp://mips.gsf.de/staff/pagel




More information about the Python-list mailing list