python string comparison similarity code example
Example 1: check string similarity python
from difflib import SequenceMatcher
def similar(a, b):
return SequenceMatcher(None, a, b).ratio()
>>> similar("Apple","Appel")
0.8
>>> similar("Apple","Mango")
0.0
Example 2: likeliness python
from difflib import SequenceMatcher
def similar(a, b):
return SequenceMatcher(None, a, b).ratio()