我收到以下错误。有人知道如何获取与大代码点相对应的Unicode字符吗?谢谢。
Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 29 2018, 20:59:26)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> unichr(119964)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: unichr() arg not in range(0x10000) (narrow Python build)
答案 0 :(得分:1)
好像您的python被配置为UCS2。从文档中
返回一个字符的Unicode字符串,其Unicode代码为 整数i。例如,unichr(97)返回字符串u'a'。这是 Unicode字符串的ord()的逆函数。有效范围 参数取决于Python的配置方式-可能是UCS2 [0..0xFFFF]或UCS4 [0..0x10FFFF]。否则将引发ValueError。对于 ASCII和8位字符串,请参见chr()。
正如上面在评论this中发布的问题一样,我有各种答案,可以为您提供解决方法。