Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
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
上記のコードを使用しましたが、得られた出力は0.0です。どうすれば有効な答えを得ることができますか?
SequenceMatcher の最初のパラメーターを忘れました。
>>> import difflib >>> >>> a='abcd' >>> b='ab123' >>> seq=difflib.SequenceMatcher(None, a,b) >>> d=seq.ratio()*100 >>> print d 44.4444444444
http://docs.python.org/library/difflib.html