Home  >  Article  >  Backend Development  >  Module 'thefuzz' has no attribute 'partial_ratio' and other strange errors

Module 'thefuzz' has no attribute 'partial_ratio' and other strange errors

王林
王林forward
2024-02-09 12:30:15896browse

Module thefuzz has no attribute partial_ratio and other strange errors

Question content

Have been trying to use thefuzz to compare two different lists and got the above error, which doesn't seem right. I've commented out everything else in the code except the two test lines below, but I still get the error. I also tried fuzz.ratio, fuzz.token_sort_ratio and fuzz.token_set_ratio, but got an error every time.

import thefuzz as fuzz

fuzz.partial_ratio("fuzzy was a bear", "wuzzy fuzzy was a bear")

Correct answer


You want

import thefuzz.fuzz as fuzz

or

from thefuzz import fuzz

Because this is where the functionality you want

Usage section of thefuzz readme file (https://github.com/seatgeek/thefuzz/blob/master/readme .rst) Suggestions:

from thefuzz import fuzz
from thefuzz import process

The above is the detailed content of Module 'thefuzz' has no attribute 'partial_ratio' and other strange errors. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:stackoverflow.com. If there is any infringement, please contact admin@php.cn delete