2019-02-19
阅读量:
865
python中能输出的最大整数位是多少
考虑下面的Python程序。
# A Python program to demonstrate that we can store
# large numbers in Python
x = 10000000000000000000000000000000000000000000;
x = x + 1
print (x)
输出:
10000000000000000000000000000000000000000001
在Python中,整数的值不受位数的限制,可以扩展到可用内存的限制。因此,我们永远不需要任何特殊的安排来存储大数字。
作为旁注,在Python 3中,对于所有类型的整数,只有一种类型“int”。在Python 2.7中。有两种不同的类型“int”(32位)和“long int”与Python 3.x的“int”相同,即可以存储任意大的数字。
# A Python program to show that there are two types in
# Python 2.7 : int and long int
# And in Python 3 there is only one type : int
x = 10
print(type(x))
x = 10000000000000000000000000000000000000000000
print(type(x))
Python 3中的输出:
<type'int'>
<type'int'>






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
1条评论