PHP前端开发

模块“thefuzz”没有属性“partial_ratio”和其他奇怪的错误

百变鹏仔 1个月前 (01-18) #Python
文章标签 模块
问题内容

一直在尝试使用thefuzz来比较两个不同的列表,并得到了上面的错误,这似乎不对。除了下面的两个测试行之外,我已经注释掉了代码中的其他所有内容,但仍然出现错误。我还尝试过 fuzz.ratio、fuzz.token_sort_ratio 和 fuzz.token_set_ratio,但每次都会出错。

import thefuzz as fuzzfuzz.partial_ratio("fuzzy was a bear", "wuzzy fuzzy was a bear")

正确答案


你想要

import thefuzz.fuzz as fuzz

或者

from thefuzz import fuzz

因为这是你想要的功能的地方

thefuzz 自述文件的使用部分(https://github.com/seatgeek/thefuzz/blob/master/readme .rst)建议:

from thefuzz import fuzzfrom thefuzz import process