模糊匹配-搜索提示

python里有个很方便的搜索提示的库FuzzyWuzzy

pip install FuzzyWuzzy
pip install python-Levenshtein 

引用方法

from fuzzywuzzy import fuzz
from fuzzywuzzy import process

从库中找到最相近的字符串

choices = ["河南省", "郑州市", "湖北省", "武汉市","郑州人"]
answer=process.extract("郑州", choices,limit=2)
[('郑州市', 90), ('郑州人', 90)]

你可能感兴趣的:(模糊匹配-搜索提示)