string to big int
Andrew Koenig
ark at research.att.com
Sat Aug 31 12:41:21 EDT 2002
Axel> Hi, Im wondering how to convert a string which contains a huge integer
Axel> ("10000000000007") to a real integer (type int). When I ask int() to
Axel> this it replies:
Axel> Traceback (most recent call last):
Axel> File "C:\prime.py", line 43, in ?
Axel> main()
Axel> File "C:\prime.py", line 29, in main
Axel> no = int( argv)
Axel> ValueError: int() literal too large: 10000000000007
Axel> any ideas?
You can't represent 10000000000007 as an int in most Python
implementations, so use a long instead:
>>> long("10000000000007")
10000000000007L
--
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark
More information about the Python-list
mailing list