我正在运用2个列表理解来做我的工作
actual_skill_list = [process.extractOne(skill, lookup_skill_dict.get(skill.lower()[0], set()), scorer=fuzz.QRatio)for skill in skill_list]
actual_skill_list = [x for x, y in actual_skill_list if y > 80]
process.extractOne
返回2值-匹配及其得分,例如("dkjbdsk", 80)
我正在尝试将上述两个列表理解合并为一个。我尝试这样做-
actual_skill_list = [x for skill in skill_list for x, y in process.extractOne(
skill, lookup_skill_dict.get(skill.lower()[0], set()), scorer=fuzz.QRatio) if y >= 80]
它给予-Traceback: <class 'ValueError'>: too many values to unpack (expected 2)
我不确定自己在做什么错
答案 0 :(得分:1)
您缺少列表括号:
actual_skill_list = [x for skill in skill_list for x, y in
[process.extractOne(
skill, lookup_skill_dict.get(skill.lower()[0], set()),
scorer=fuzz.QRatio)] if y >= 80]