擅长:python、mysql、java
<p>如果您阅读了关于ifflib.get_close_matches()的Python文档
<a href="https://docs.python.org/3/library/difflib.html" rel="nofollow noreferrer">https://docs.python.org/3/library/difflib.html</a>
它返回所有可能的最佳匹配。
方法签名:
difflib.get_close_匹配(单词,可能性,n=3,截止值=0.6)</p>
<p>这里n是要返回的最大接近匹配数。所以我想你可以把这个作为1通过</p>
<pre><code>>>> [difflib.get_close_matches(x.lower().strip(), sent.split(),1)[0] for x in list1]
['twn', 'tddy', 'chicken.', 'went']
</code></pre>