2019独角兽企业重金招聘Python工程师标准>>>
def censor(text,word):
temp=text.split(" ")
for i in range(0,len(temp)):
if temp[i]==word:
temp[i]= '*'*len(word)
return " ".join(temp)
函数将text中的word替换成**
str.split(a,b) 有俩参数,a代表分割标志符,b代表分割次数。