Linux 和 Windows 上的 Python sys.maxint、sys.maxunicode

2024-02-28

在 64 位 Debian Linux 6 上:

Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.maxint
9223372036854775807
>>> sys.maxunicode
1114111

在 64 位 Windows 7 上:

Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.maxint
2147483647
>>> sys.maxunicode
65535

两个操作系统都是 64 位。他们有sys.maxunicode,根据维基百科 http://en.wikipedia.org/wiki/Unicode#Architecture_and_terminologyunicode 中有 1,114,112 个代码点。 Windows 上的 sys.maxunicode 是错误的吗?

为什么他们有不同的 sys.maxint ?


我不知道你的问题是什么,但是sys.maxunicode is not wrong在 Windows 上。

See the docs http://docs.python.org/library/sys.html#sys.maxunicode:

sys.maxunicode

给出 Unicode 字符支持的最大代码点的整数。该值取决于配置选项 指定 Unicode 字符存储为 UCS-2 还是 UCS-4。

Windows 上的 Python 使用 UCS-2,因此最大代码点为 65,535(并且补充平面字符由 2*16 位“代理对”编码)。

About sys.maxint,这显示了 Python 2 从“简单整数”切换到的点(123) 到“长整数”(12345678987654321L)。显然Python for Windows使用32位,Python for Linux使用64位。从 Python 3 开始,这已变得无关紧要,因为简单整数类型和长整数类型已合并为一种。所以,sys.maxint从 Python 3 中消失了。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Linux 和 Windows 上的 Python sys.maxint、sys.maxunicode 的相关文章

随机推荐