我使用fuzzywuzzy
lib得到一个字符串与Python中的另一个字符串相似的概率。你知道吗
目前,我使用for循环进行搜索,搜索非常耗时。你知道吗
以下是工作代码:
from fuzzywuzzy import fuzz
with open('all_nut_data.csv', newline='') as csvfile:
spamwriter = csv.DictReader(csvfile)
mostsimilarcs = 0
mostsimilarns = 0
for rowdata in spamwriter:
mostsimilarns = fuzz.ratio(rowdata["Food Item"].lower(), name.lower())
if mostsimilarns > mostsimilarcs:
mostsimilarcs = mostsimilarns
row1 = rowdata
如何在没有for循环的情况下优化代码?你知道吗
注*CSV文件包含600000行和17列
目前没有回答
相关问题 更多 >
编程相关推荐