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

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

王林
Release: 2024-02-09 12:30:15
forward
986 people have browsed it

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")
Copy after login


Correct answer


You want

import thefuzz.fuzz as fuzz
Copy after login

or

from thefuzz import fuzz
Copy after login

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
Copy after login

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!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template