Convert long integer to string

Simon Brunning SBrunning at trisystems.co.uk
Thu May 24 04:15:45 EDT 2001


> From:	Roman Suzi [SMTP:rnd at onego.ru]
> >  how convert long integer ( >2147483647 ) to string whithout "L" on end?
> 
> >>> str(1222222222222222222222222222222222222222222222L)
> '1222222222222222222222222222222222222222222222'
 
Note that this behaviour was introduced in version 2.0 of Python. (Or was it
1.6?)

The Python 1.5.2 version of str would leave the 'L' on the end. If you are
using an old version, you'll just have to chop it off if it's there:

spam = str(12345678901234567890)
if spam[-1] in 'lL': spam = spam[:-1]

Cheers,
Simon Brunning
TriSystems Ltd.
sbrunning at trisystems.co.uk




-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.




More information about the Python-list mailing list