我有这个清单:
words = ['how', 'much', 'is[br]', 'the', 'fish[br]', 'no', 'really']
Run Code Online (Sandbox Code Playgroud)
我想要的是取代[br]一些类似的奇妙价值<br />,从而得到一个新的清单:
words = ['how', 'much', 'is<br />', 'the', 'fish<br />', 'no', 'really']
Run Code Online (Sandbox Code Playgroud) 我想做什么(在Clojure中):
例如,我有一个需要删除的单词向量:
(def forbidden-words [":)" "the" "." "," " " ...many more...])
Run Code Online (Sandbox Code Playgroud)
......和一个字符串向量:
(def strings ["the movie list" "this.is.a.string" "haha :)" ...many more...])
Run Code Online (Sandbox Code Playgroud)
因此,应从每个字符串中删除每个禁用的单词,在这种情况下,结果将是:["movie list""thisisastring""haha"].
这该怎么做 ?
例如:
item =['the dog is gone', 'the dog and cat is gone']
words= ['dog','cat']
Run Code Online (Sandbox Code Playgroud)
我希望能够过滤掉它dog,cat所以它会读取:
item=['the is gone', 'the and is gone']
Run Code Online (Sandbox Code Playgroud)
item1=[]
for w in words:
for line in item:
if w in line:
j=gg.replace(it,'')
item1.append(j)
Run Code Online (Sandbox Code Playgroud)
我得到以下内容:
['the is gone', 'the cat and is gone', 'the and dog is gone']
Run Code Online (Sandbox Code Playgroud)