python 实现敏感词屏蔽小程序
2024-10-20 20:31:40
有一个文件,里面有一些敏感词汇,如果输入这些词,就用**代替,然后输出。
敏感词汇
dictionary.txt
文件内容:
SB,傻B,傻逼,妈,日,shabi,操,sb,金三胖
代码实现主体:
f = open('dictionary.txt', 'r', encoding='utf-8')
dic = f.read().split(',')
string = input("请发言:\n")
for word in dic:
if word in string:
count = len(word)
string = string.replace(word, '*'*count)
print("你说:", string)
运行结果:
最新文章
- iOS9支付宝无法调起客户端
- 我与ADO.NET二三事(2)
- windows下docker环境设置
- JavaWeb 6 Http
- 添加常驻Notification
- Android系统编译脚本理解
- 用Python操作Mysql
- Hadoop源码解析之: TextInputFormat如何处理跨split的行
- Struts2学习笔记⑧
- javaweb-1-B/S初论
- Android真机安装sqlite3的方法
- bootstrap的模态框
- 第一次写html网页
- Oracle day03 连表查询
- 2、每日复习点--ConcurrentHashMap vs HashMap vs HashTable
- Oracle 存储过程笔记.
- BZOJ 5467 Slay the Spire
- 关于 version control
- HTTP文件上传服务器-支持超大文件HTTP断点续传的实现办法
- 【大数据系列】hadoop2.0中的jobtracker和tasktracker哪里去了