Convert long integer to string

John Machin machin_john_888 at hotmail.com
Thu May 24 05:28:56 EDT 2001


erik <erik at seznam.cz> wrote in message news:<3B0CAC7C.DCF2B091 at seznam.cz>...
> Hi,
>  how convert long integer ( >2147483647 ) to string whithout "L" on end?

Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32
>>> x = 12345678901L
>>> str(x)
'12345678901'
>>> repr(x)
'12345678901L'
>>> "%d" % x
'12345678901'
>>>
In version 1.5.2, the %d example causes an exception "Overflow Error:
long int too long to convert" --- obviously a bug that has been fixed.
Before version 1.6, str() acted like repr(). If indeed you are using
version 1.x, you may want to consider upgrading.



More information about the Python-list mailing list