2
"""Return a copy of str1 with characters from str2 removed.
filter_string(string, string) -> string
"""
for a in str1:
if a in str2:
str1.replace(a,"")
return str1
我关闭了吗?Python - 返回一个字符串的函数,从另一个字符串中删除字符
str1和str2的包含变量字符串
到目前为止我的输出是21 oramrfrrdonRsmsov CREEA^h蒂特twrch
所需的输出是21mdnRmvhiwh
作为一个侧面说明,你可以只使用这个:'STR1 = str1.translate(无,STR2)' – Volatility 2013-03-17 03:27:46
热潮绝对的传奇^好人缘你,先生。 – Josh123 2013-03-17 03:31:38
在Python 3中:'str1 = re.sub('[%s]'%re.escape(str2),'',str1)'(忽略包含多个Unicode码点的字符问题)。 – jfs 2013-03-17 05:48:10