special Chinese characters comparison [closed]

2019-09-21 11:43发布

问题:

. There are something misunderstanding when comparing two characters "李","李".

>>> "李" == "李"
False

>>> id("李") # fisrt one
140041303457584

>>> id("李") # second one
140041303457584

. The first character "李“ id is equal to the second "李" id, but when i try to compare their id to see what happen:

>>> id("李") == id("李")
False

. However, I tried to use chrome "Ctrl + F" that searching the first "李" and matched the second "李".

. Does anyone know what happens? what should I do to fix this let the first "李" equal to the second "李"?

回答1:

I think it's just a coincidence that two character looks the same. like:

>>> "ᴀ" == "A"
False
>>> "С" == "C"
False

Visit unicode table, and you will find that the first character(unicode: 674e) is the normal character of Chinese, the second one(unicode: f9e1) is a special character that happends to look like the same. But they are indeed different characters.