【发布时间】:2022-02-16 06:11:24
【问题描述】:
我正在尝试使用以下代码根据另一个 list2 过滤 list1:
import csv
with open('screen.csv') as f: #A file with a list of all the article titles
reader = csv.reader(f)
list1 = list(reader)
print(list1)
list2 = ["Knowledge Management", "modeling language"] #key words that article title should have (at least one of them)
list2 = [str(x) for x in list2]
occur = [i for i in list1 for j in list2 if str(j) in i]
print(occur)
但输出为空。
【问题讨论】:
-
也许那些确切的短语不存在?
-
这里是我手动搜索的标题之一
An Integrated Method for Knowledge Management in Product Configuration Projects,其中包含知识管理来测试它