Not*_*der 29 python python-2.x exponent
如果您已经注意到,python会在大指数结果的末尾添加一个L,如下所示:
>>> 25 ** 25
88817841970012523233890533447265625L
Run Code Online (Sandbox Code Playgroud)
做一些测试后,我发现,任何数量低于10不包括大号.例如:
>>> 9 ** 9
387420489
Run Code Online (Sandbox Code Playgroud)
这很奇怪,所以,为什么会发生这种情况,有什么方法可以阻止它吗?所有帮助表示赞赏!
Col*_*lin 42
Python支持任意精度整数,这意味着您能够表示比普通32或64位整数类型更大的数字.该L告诉你什么时候文字是这样的类型,而不是一个普通的整数.
注意,L它只显示在解释器输出中,它只是表示类型.如果您打印该结果:
>>> print(25 ** 25)
88817841970012523233890533447265625
Run Code Online (Sandbox Code Playgroud)
在L没有得到打印.
在Python 3中,这些类型已合并,因此Python 3输出:
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 24 ** 24
1333735776850284124449081472843776
Run Code Online (Sandbox Code Playgroud)