为什么 Python 将符号“²”检测为数字?

Kia*_*RST 11 python string

有人可以说“²”是符号还是数字?(alt+1277,二的幂)

print("²".isdigit())
# True
print("²".isnumeric())
# True
Run Code Online (Sandbox Code Playgroud)

因为 Python 说它是一个数字,但它实际上不是一个数字。我错了吗?或者这是一个错误?

che*_*ner 17

它被明确记录为数字:

海峡 isdigit()

True if all characters in the string are digits and there is at least one character, 否则返回False`。数字包括十进制字符和需要特殊处理的数字,例如 兼容性上标数字。这涵盖了不能用于​​形成以 10 为基数的数字的数字,例如 Kharosthi 数字。正式地,数字是具有属性值 Numeric_Type=Digit 或 Numeric_Type=Decimal 的字符。

关于Numeric_Type,这是由 Unicode 定义的:

Numeric_Type=数字

位置十进制字符的变体(Numeric_Type=Decimal)或其序列。这些包括上标/下标、封闭或通过添加括号、点或逗号等字符进行修饰。