Python开发敏感词语过滤程序
开发敏感词语过滤程序,提示用户输入评论内容,如果用户输入的内容中包含特殊的字符: 敏感词列表 li = ["苍老师","东京热",”武藤兰”,”波多野结衣”] 则将用户输入的内容中的敏感词汇替换成***,并添加到一个列表中;如果用户输入的内容没有敏感词汇,则直接添加到上述的列表中。 content = input('请输入你的内容:') li = ["苍老师","东京热","武藤兰","波多野结衣"] i = 0 while i < 4: for li[i] in content: li1 = content.replace('苍老师','***') li2 = li1.replace('东京热','***') li3 = li2.replace('武藤兰','***') li4 = li3.replace('波多野结衣','***') else: pass i += 1
Golang版本
func main(){
Words :=[]string{}
SensibilityWords :=[]string{"苍老师","东京热","武藤兰","波多野结衣"}
for {
var comment string
fmt.Scanln(&comment)
for _,str :=range SensibilityWords{
fmt.Printf("str: %#v\n",str)
if strings.Contains(comment,str){
comment = strings.Replace(comment, str, "*", -1)
}
}
Words=append(Words,comment)
fmt.Println(Words)
}
}
提供面试指导、模拟面试、简历项目优化和职业规划等
负责SRE团队,运维架构(DevOps)、微服务流量治理(K8s、Ingress)、稳定性和可测性系统建设(Prometheus、EFK、Loki)

浙公网安备 33010602011771号