【发布时间】:2020-06-14 08:34:49
【问题描述】:
我需要我的代码接受 2 个输入,一个字符串和第二个字符串。换句话说,第一个字符串是某种句子,第二个字符串只是要从整个句子中删除的几个字母。示例:
remove("This is as it is.", "is") == 'Th as it .'
到目前为止,我有:
def remove(word, reword):
s = set(reword)
return (x for x in word if x not in s)
remove("This is as it is.", "is")
print(word)
【问题讨论】:
-
使用
.replace()