考虑下面的Python 程序。
Python3
# A Python program to demonstrate that we can store
# large numbers in Python
x = 10000000000000000000000000000000000000000000
x = x + 1
print (x)
输出 :
10000000000000000000000000000000000000000001
在Python中,整数的值不受位数的限制,并且可以扩展到可用内存的限制(来源:this和this)。因此,我们不需要任何特殊的安排来存储大数(想象一下在 C/C++ 中进行上述算术)。
附带说明一下,在 Python 3 中,所有类型的整数都只有一种类型“int