Python 为什么';Unicode数据不能识别某些字符吗?

Python 为什么';Unicode数据不能识别某些字符吗?,python,unicode,Python,Unicode,至少在Python 2中,unicodedata.name()无法识别某些字符 ActivePython 2.7.0.2 (ActiveState Software Inc.) based on Python 2.7 (r27:82500, Aug 23 2010, 17:17:51) [MSC v.1500 64 bit (AMD64)] on win 32 Type "help", "copyright", "credits" or "license" for more informatio

至少在Python 2中,
unicodedata.name()
无法识别某些字符

ActivePython 2.7.0.2 (ActiveState Software Inc.) based on
Python 2.7 (r27:82500, Aug 23 2010, 17:17:51) [MSC v.1500 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> from unicodedata import name
>>> print(u'\n')


>>> name(u'\n')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: no such name
>>> name(u'a')
'LATIN SMALL LETTER A'
>>>
ActivePython 2.7.0.2(ActiveState软件公司)基于
Python 2.7(r27:82500,2010年8月23日,17:17:51)[MSC v.1500 64位(AMD64)]关于win
32
有关详细信息,请键入“帮助”、“版权”、“信用证”或“许可证”。
>>>从Unicode数据导入名称
>>>打印(u'\n')
>>>名称(u'\n')
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
ValueError:没有这样的名称
>>>名称(u'a')
“拉丁文小写字母A”
>>>
(第一个
print
是为了证明Python本身将
u'\n'
识别为新行。)

当然是Unicode字符
\n
,它有一个名称,特别是“换行符”

注意
unicodedata.lookup('LINE FEED')
unicodedata.lookup('u'LINE FEED')
都给出了一个关键错误:未定义的字符名。

unicodedata.name()查找依赖于的第2列(Python 2.7使用Unicode 5.2.0)


如果该名称在python上以
开头,则
3.4.1
上的相同输出似乎在我的计算机上Unicode表有洞:-),使用python3.4
name('\n')
失败,但
'\n{linefeed}'
查找('linefeed')
一样有效。在python2上,所有操作都失败。@Bakuriu是的,这里也一样,
查找功能也可以工作;但是
name
失败。@AaronDigulla:no,
\n
没有名字(除了
)<代码>换行符
是一个别名。
000A;<control>;Cc;0;B;;;;;N;LINE FEED (LF);;;;