【发布时间】:2021-11-12 16:47:28
【问题描述】:
我想识别列表中的单词是否在输入字符串中,如果是,则删除该单词。
我试过了:
words = ["youtube","search youtube","play music"]
Inp = "search youtube Rockstar"
if words in Inp:
Inp = Inp.replace(words,"")
想要的输出是:
Inp = "Rockstar"
【问题讨论】:
-
问题与
artificial-intelligence无关,请不要发送无关标签(已删除)。
标签: python python-3.x string automation