python 2.2 string conversion ?

ken kericks272 at earthlink.net
Thu Jul 24 01:31:17 EDT 2003


I've been looking for a solution to a string to long conversion problem that
I've run into

>>> x = 'e10ea210'
>>> print x
e10ea210
>>> y=long(x)
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in ?
    y=long(x)
ValueError: invalid literal for long(): e10ea210
>>> x='0xe10ea210'
>>> print x
0xe10ea210
>>> y=long(x)
Traceback (most recent call last):
  File "<pyshell#5>", line 1, in ?
    y=long(x)
ValueError: invalid literal for long(): 0xe10ea210
>>> x="e10ea210"
>>> y=long(x)
Traceback (most recent call last):
  File "<pyshell#7>", line 1, in ?
    y=long(x)
ValueError: invalid literal for long(): e10ea210
>>> x="0xe10ea210"
>>> y=long(x)
Traceback (most recent call last):
  File "<pyshell#9>", line 1, in ?
    y=long(x)
ValueError: invalid literal for long(): 0xe10ea210
>>>

What am I doing wrong?

TIA






More information about the Python-list mailing list