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

问题描述 投票:3回答:1

[尝试通过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'"
python python-2.7 unicode python-2.x
1个回答
5
投票

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

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

[不幸的是,这意味着几乎所有Emoji and hieroglyphs都使您不走运(如果您是埃及人)。

© www.soinside.com 2019 - 2024. All rights reserved.