>>> import sys
>>> sys.version_info
sys.version_info(major=2, minor=7, micro=2, releaselevel='final', serial=0)
>>> import unicodedata
>>> unicodedata.unidata_version
'5.2.0'
这意味着我的 Python 版本应该有 Unicode 5.2.0。
但是当我转到list of newly added unicode chars in version 5.2.0时并打印这样的字符,它不被识别:
>>> print u"\u0803"
ࠃ
Chars from 5.1.0然而被认可:
>>> print u"\u03CF"
Ϗ
那么我应该总是计算一个低于 unicodedata.unidata_version
实际输出的版本还是我误解了什么?
最佳答案
您将终端可以打印的内容与 Python 对 unicode 字符的了解混淆了。
您的终端字体无法识别这些代码点。 Python 可以很好地处理它们:
>>> import unicodedata
>>> unicodedata.category(u'\u0803')
'Lo'
>>> unicodedata.name(u'\u0803')
'SAMARITAN LETTER DALAT'
>>> unicodedata.category(u'\u03CF')
'Lu'
>>> unicodedata.name(u'\u03CF')
'GREEK CAPITAL KAI SYMBOL'
具有讽刺意味的是,我的浏览器使用的字体没有为任一代码点定义图像。您的帖子向我显示了两个占位符:
关于python - unicodedata.unidata_version 打印错误的 unicode 版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13609210/