首頁  >  文章  >  後端開發  >  模組「thefuzz」沒有屬性「partial_ratio」和其他奇怪的錯誤

模組「thefuzz」沒有屬性「partial_ratio」和其他奇怪的錯誤

王林
王林轉載
2024-02-09 12:30:15897瀏覽

模組「thefuzz」沒有屬性「partial_ratio」和其他奇怪的錯誤

問題內容

一直在嘗試使用thefuzz來比較兩個不同的列表,並得到了上面的錯誤,這似乎不對。除了下面的兩個測試行之外,我已經註解掉了程式碼中的其他所有內容,但仍然出現錯誤。我還嘗試過 fuzz.ratio、fuzz.token_sort_ratio 和 fuzz.token_set_ratio,但每次都會出錯。

import thefuzz as fuzz

fuzz.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 fuzz
from thefuzz import process

以上是模組「thefuzz」沒有屬性「partial_ratio」和其他奇怪的錯誤的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:stackoverflow.com。如有侵權,請聯絡admin@php.cn刪除