AttributeError:模块'sys'没有属性'maxint'

Tru*_*rux 9 python sys python-3.x

我正在尝试使用Python 3.7运行以下代码:

import sys
print(sys.maxint)
Run Code Online (Sandbox Code Playgroud)

但是我收到一个错误:

D:\Python3.7\python.exe "D:/PyCharm 2017.2.3/Workplace/maximizer.py"
Traceback (most recent call last):
File "D:/PyCharm 2017.2.3/Workplace/maximizer.py", line 2, in <module>
    print(sys.maxint)
AttributeError: module 'sys' has no attribute 'maxint'
Run Code Online (Sandbox Code Playgroud)

我如何解决它?

Jac*_*IRR 15

在python3中,sys.maxint改为sys.maxsize.

以下是值:

Python2

>>> sys.maxint
9223372036854775807
Run Code Online (Sandbox Code Playgroud)

Python3

>>> sys.maxsize
9223372036854775807
Run Code Online (Sandbox Code Playgroud)

在同一平台上,值匹配.该值通常2**31 - 1位于32位平台和2**63 - 164位平台上.

将您的呼叫替换为maxintwith maxsize将停止此特定的Traceback.