str.isnumeric https://docs.python.org/3/library/stdtypes.html?highlight=isnumeric#str.isnumeric对于“具有 Unicode 数值属性的所有字符”,记录为 true。
The canonical reference for that property is the Unicode Character Database http://www.unicode.org/ucd/. The information we need can be dug out of http://www.unicode.org/Public/9.0.0/ucd/UnicodeData.txt http://www.unicode.org/Public/9.0.0/ucd/UnicodeData.txt , which is the latest version at time of writing (late 2016) (warning: 1.5MB text file). It's a little tricky to read (the documentation is in UAX#44 http://www.unicode.org/reports/tr44/). I'm going to show its entry for a character that is numeric first, U+3023 HANGZHOU NUMERAL THREE (〣)
3023;HANGZHOU NUMERAL THREE;Nl;0;L;;;;3;N;;;;;
第八个分号分隔字段是“数值”属性;在本例中,它的值为3,与角色的名字一致。蟒蛇的str.isnumeric
当且仅当该字段非空时才为 true。可以直接使用查询unicodedata.numeric https://docs.python.org/3/library/unicodedata.html#unicodedata.numeric.
The third以分号分隔的字段是一个两个字符的代码,给出“一般类别 http://www.unicode.org/reports/tr44/#General_Category_Values“;在本例中为“Nl”。大多数(但不是全部)具有数值的字符都属于“数字”类别之一(类别代码的第一个字母是 N)。例外情况是所有汉字,根据上下文,可能表示也可能不表示数字;请参阅UAX#38 http://www.unicode.org/reports/tr38/.
现在,您所询问的角色:
2183;ROMAN NUMERAL REVERSED ONE HUNDRED;Lu;0;L ;;;;;N;;; ;2184;
2184;LATIN SMALL LETTER REVERSED C ;Ll;0;L ;;;;;N;;;2183; ;2183
218A;TURNED DIGIT TWO ;So;0;ON;;;;;N;;; ; ;
218B;TURNED DIGIT THREE ;So;0;ON;;;;;N;;; ; ;
这些字符做not分配了一个数值,因此 Python 的行为是正确的。
注:每https://docs.python.org/3.6/whatsnew/3.6.html https://docs.python.org/3.6/whatsnew/3.6.html,Python只会在3.6版本中更新到Unicode 9.0.0;然而,AFAICT这些字符已经很长时间没有改变了。
(“为什么这些字符没有数值?”这个问题只有 Unicode 联盟才能明确回答;如果您有兴趣,我建议您在他们的一个网站上提出这个问题)邮件列表 http://www.unicode.org/consortium/distlist.html.)