python敏感词过滤

时间:2020-04-03 19:46:14   收藏:0   阅读:62

题目:现在基本上所有的网站都需要设置敏感词过滤,编程查找与敏感词列表相匹配的字符串,如果找到以*号替换,最终得到替换后的字符串。

假设敏感词列表由以下词组成:垃圾,陷阱,不要脸,内幕,辣鸡。

words = ("垃圾","陷阱","不要脸","内幕","辣鸡")
text = input()
for word in words:
    if word in text:
        text = text.replace(word, "*")
print(text)

 

原文:https://www.cnblogs.com/L-1008/p/12628483.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!