gpt4 book ai didi

python - 属性错误 : module 'sys' has no attribute 'maxint'

转载 作者:太空狗 更新时间:2023-10-29 20:41:29 31 4
gpt4 key购买 nike

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

import sys
print(sys.maxint)

但是我得到一个错误:

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'

我该如何解决?

最佳答案

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

以下是值:

Python2

>>> sys.maxint
9223372036854775807

Python3

>>> sys.maxsize
9223372036854775807

在同一平台上,值匹配。该值在 32 位平台上通常为 2**31 - 1,在 64 位平台上通常为 2**63 - 1

将对 maxint 的调用替换为 maxsize 将停止此特定的 Traceback。

关于python - 属性错误 : module 'sys' has no attribute 'maxint' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47027354/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com