如何通过描述性名称查找unicode字符?

时间:2014-07-31 12:12:19

标签: python unicode python-2.x

尝试通过python 2.7中的(唯一)名称获取unicode字符。我在docs中找到的方法对我不起作用:

>>> import unicodedata
>>> print unicodedata.lookup('PILE OF POO')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: "undefined character name 'PILE OF POO'"

1 个答案:

答案 0 :(得分:5)

问题是,PILE OF POO是用Unicode 6引入的。但是,unicodedata的数据大多是较旧的,5.X版本左右。文档说:

  

该模块使用与UnicodeData文件格式5.2.0定义的相同名称和符号(请参阅http://www.unicode.org/reports/tr44/tr44-4.html)。

不幸的是,这意味着你几乎所有Emoji and hieroglyphs都没有运气(如果你进入了埃及学)。

相关问题