2024-09-29 19:13:47 发布
网友
当我比较这两个字符串时,得到的值是False。在
False
a = "comentar" b = "️comentar" print(a == b) # False
我怎么能修好这个?我尝试过改变两个字符串的编码,但没有任何效果。在
你可以在这里试试:https://onlinegdb.com/HJ8xYLPq4
它们不完全相同。第一个字符是不同的(尽管它看起来和肉眼一样)
试试看
print([ord(c) for c in a]) print([ord(c) for c in b])
如果您可以忽略像这样的小差异,请尝试:
from difflib import SequenceMatcher word_1 = "comentar" word_2 = " comentar" result = SequenceMatcher(a=word_1, b=word_2).ratio() > 0.9 print(result)
这将返回True
它们不完全相同。第一个字符是不同的(尽管它看起来和肉眼一样)
试试看
如果您可以忽略像这样的小差异,请尝试:
这将返回True
相关问题 更多 >
编程相关推荐