Is there any built in function that converts ASCII to integer or vice versa
in Python?
Thanks!
--
http://mail.python.org/mailman/listinfo/python-list
John wrote:
> Is there any built in function that converts ASCII to integer or vice versa
> in Python?
>
> Thanks!
>
>
You probably should go through the tutorial ASAP that is located here:
http://docs.python.org/tut/
Convert ascii string to integer:
a='1'
b=int(a)
Convert integer to ascii
On Feb 22, 5:43 pm, "John" <[EMAIL PROTECTED]> wrote:
> Is there any built in function that converts ASCII to integer or vice versa
> in Python?
>
> Thanks!
Try int.
ie.
try:
int_val = int(str_val)
except ValueError:
# conversion failed
Keir.
--
Keir Robinson
Sometimes a scream is better
John wrote:
> Is there any built in function that converts ASCII to integer or vice
> versa in Python?
>
> Thanks!
>>> int('10')
10
>>> str(10)
'10'
>>>
--
http://mail.python.org/mailman/listinfo/python-list
Or perhaps...
ord ("a")
97
chr (97)
'a'
On 2/22/07, hg <[EMAIL PROTECTED]> wrote:
John wrote:
> Is there any built in function that converts ASCII to integer or vice
> versa in Python?
>
> Thanks!
>>> int('10')
10
>>> str(10)
'10'
>>>
--
http://mail.python.org/mailman/listinfo/pytho
I just found ord(c), which convert ascii to integer.
Anybody know what the reverse is?
"John" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Is there any built in function that converts ASCII to integer or vice
versa
> in Python?
>
> Thanks!
>
>
--
http://mail.python.org/mailman
"John" <[EMAIL PROTECTED]> writes:
> 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", "copy
John wrote:
> I just found ord(c), which convert ascii to integer.
>
> Anybody know what the reverse is?
>
> "John" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> Is there any built in function that converts ASCII to integer or vice
> versa
>> in Python?
>>
>> Thanks!
>>
>>
>
>
"John" <[EMAIL PROTECTED]> writes:
> I just found ord(c), which convert ascii to integer.
> Anybody know what the reverse is?
chr(i)
--
http://mail.python.org/mailman/listinfo/python-list
On Feb 22, 6:35 pm, Lloyd Zusman <[EMAIL PROTECTED]> wrote:
> "John" <[EMAIL PROTECTED]> writes:
> > 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)
> [
On Feb 23, 5:23 am, "John" <[EMAIL PROTECTED]> wrote:
> I just found ord(c), which convert ascii to integer.
ord('\xff') -> 255
ord(unichr(666)) -> 666
What ascii?
What is stopping you from reading the documentation section on built-
in functions (http://docs.python.org/lib/built-in-funcs.html)?
Some people spend many buck bying guessing games ... be nice !
hg
--
http://mail.python.org/mailman/listinfo/python-list
12 matches
Mail list logo