python函数func(str1,str2)

python编写一个函数func(str1, str2) ,将字符串str1中出现的字符串str2删除,然后作为函数的结果返回


import re

def func(str1,str2):
    result=re.sub(str2,'',str1)
    return result

使用re的sub替换功能,有用请点击采纳

def func(str1,str2):
    return str1.replace(str2,'')