Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax an...
I just found ord(c), which convert ascii to integer.
>
Anybody know what the reverse is?
>
"John" <rds1226@sh163. netwrote in message
news:erkknl$6d4 p$1@netnews.upe nn.edu...
>Is there any built in function that converts ASCII to integer or vice
versa
>in Python?
>>
>Thanks!
>>
>>
>
>
The phrasing of your question threw us all. What you want is chr
I just found ord(c), which convert ascii to integer.
>
Anybody know what the reverse is?
The inverse of "ord" is "chr":
% python
Python 2.5 (r25:51908, Jan 5 2007, 00:12:45)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.
>>ord('i')
105
>>chr(105)
'i'
>>>
IIRC, the first use of the names "ord" and "chr" for these functions
appeared in the Basic language in the 1960's ... in case anyone is
interested in this bit of historical trivia.
On Feb 22, 6:35 pm, Lloyd Zusman <l...@asfast.co mwrote:
"John" <rds1...@sh163. netwrites:
I just found ord(c), which convert ascii to integer.
>
Anybody know what the reverse is?
>
The inverse of "ord" is "chr":
>
% python
Python 2.5 (r25:51908, Jan 5 2007, 00:12:45)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.
>>ord('i')
105
>>chr(105)
'i'
>>>
>
IIRC, the first use of the names "ord" and "chr" for these functions
appeared in the Basic language in the 1960's ... in case anyone is
interested in this bit of historical trivia.
>
In the versions of Basic that I've seen they were ASC (clearly ASCII)
and CHR$. I first saw ord in Pascal.
Comment