python - How to use SequenceMatcher to find similarity between two strings? -
import difflib a='abcd' b='ab123' seq=difflib.sequencematcher(a=a.lower(),b=b.lower()) seq=difflib.sequencematcher(a,b) d=seq.ratio()*100 print d
i used above code obtained output 0.0. how can valid answer?
you forgot first parameter sequencematcher.
>>> import difflib >>> >>> a='abcd' >>> b='ab123' >>> seq=difflib.sequencematcher(none, a,b) >>> d=seq.ratio()*100 >>> print d 44.4444444444
Comments
Post a Comment