There are many methods of comparing string in python. Some of the main methods are:
- Using regex
- Simple compare
- Using difflib
But one of the very easy method is by using fuzzywuzzy library that denotes two string are equal by giving similarity index. FuzzyWuzzy is a library of Python which is
used for string matching.Fuzzy string matching is the process of finding strings that match a given pattern. FuzzyWuzzy has been developed and its open-sourced by Seat methods.
Install via pip pip install fuzzywuzzy
pip install python-Levenshtein
Example :
from fuzzywuzzy import fuzz from fuzzywuzzy import process
s1 = "Mindstick"
s2 = "Mindstick"
print "FuzzyWuzzy Ratio: ", fuzz.ratio(s1, s2)
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
FuzzyWuzzy Python library :
There are many methods of comparing string in python. Some of the main methods are:
- Using regex
- Simple compare
- Using difflib
But one of the very easy method is by using fuzzywuzzy library that denotes two string are equal by giving similarity index. FuzzyWuzzy is a library of Python which is used for string matching.Fuzzy string matching is the process of finding strings that match a given pattern. FuzzyWuzzy has been developed and its open-sourced by Seat methods.
Example :