编写一个函数,接收一个字符串参数,将其中
的敏感词替换为星号,并返回替换后的结果。
def getReplace(s): wordList=["阿里巴巴","苹果","亚马逊","京东","字节","脸书"] for word in wordList: s=s.replace(word,"*"*len(word)) return s print(getReplace("阿里巴巴、亚马逊、字节和脸书是世界上最知名的公司之一。"))
编写一个函数,接收一个字符串参数,将其中
的敏感词替换为星号,并返回替换后的结果。
def getReplace(s): wordList=["阿里巴巴","苹果","亚马逊","京东","字节","脸书"] for word in wordList: s=s.replace(word,"*"*len(word)) return s print(getReplace("阿里巴巴、亚马逊、字节和脸书是世界上最知名的公司之一。"))