更新时间:2023-12-05 17:50:16
假设您有2个列表,这将满足您的要求:
assuming you have the 2 lists this will do what you want:
new_keywords = []
for k in keywords:
temp = False
for s in stops:
if s in k:
new_keywords.append(k.replace(s,""))
temp = True
if temp == False:
new_keywords.append(k)
这将创建一个您发布的列表:
This will create a list like you posted:
['nike shoes', 'nike ', 'nike ', 'nike ']
要消除双打,请执行以下操作:
To eliminate the doubles do this:
new_keywords = list(set(new_keywords))
所以最终列表如下:
['nike shoes', 'nike ']