Tyl*_*ong 5 python linux windows unicode
在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
Run Code Online (Sandbox Code Playgroud)
在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
Run Code Online (Sandbox Code Playgroud)
两种操作系统都是64位.根据维基百科,他们有sys.maxunicode 在unicode中有1,114,112个代码点.Windows上的sys.maxunicode是错误的吗?
为什么他们有不同的sys.maxint?
我不知道你的问题是什么,但在 Windows 上sys.maxunicode没有错 。
请参阅文档:
sys.maxunicode给出 Unicode 字符支持的最大代码点的整数。该值取决于指定 Unicode 字符存储为 UCS-2 还是 UCS-4 的配置选项。
Windows 上的 Python 使用 UCS-2,因此最大代码点为 65,535(并且补充平面字符由 2*16 位“代理对”编码)。
关于,这显示了 Python 2 从“简单整数”( ) 切换到“长整数”( )sys.maxint的时间点。显然Python for Windows使用32位,Python for Linux使用64位。从 Python 3 开始,这已经变得无关紧要了,因为简单整数类型和长整数类型已合并为一种。因此,它已从 Python 3 中消失。12312345678987654321Lsys.maxint