When I compare these 2 strings, the value I get is False
.
a = "comentar"
b = "️comentar"
print(a == b) # False
How could I fix this? I have tried changing the encoding of both strings but it does not have any effect.
You can try it here: https://onlinegdb.com/HJ8xYLPq4
They are not identical. The first character is different (although it looks identical to the naked eye)
Try
print([ord(c) for c in a])
print([ord(c) for c in b])
If you can ignore small differences like this one, try:
from difflib import SequenceMatcher word_1 = "comentar" word_2 = " comentar" result = SequenceMatcher(a=word_1, b=word_2).ratio() > 0.9 print(result)
This will return True
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With