有一个文件,里面有一些敏感词汇,如果输入这些词,就用**代替,然后输出。
敏感词汇
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)

运行结果:

最新文章

  1. iOS9支付宝无法调起客户端
  2. 我与ADO.NET二三事(2)
  3. windows下docker环境设置
  4. JavaWeb 6 Http
  5. 添加常驻Notification
  6. Android系统编译脚本理解
  7. 用Python操作Mysql
  8. Hadoop源码解析之: TextInputFormat如何处理跨split的行
  9. Struts2学习笔记⑧
  10. javaweb-1-B/S初论
  11. Android真机安装sqlite3的方法
  12. bootstrap的模态框
  13. 第一次写html网页
  14. Oracle day03 连表查询
  15. 2、每日复习点--ConcurrentHashMap vs HashMap vs HashTable
  16. Oracle 存储过程笔记.
  17. BZOJ 5467 Slay the Spire
  18. 关于 version control
  19. HTTP文件上传服务器-支持超大文件HTTP断点续传的实现办法
  20. 【大数据系列】hadoop2.0中的jobtracker和tasktracker哪里去了

热门文章

  1. In case of failure
  2. c++ stl常用
  3. centos7装NVIDIA显卡驱动
  4. Codeforces 595B. Pasha and Phone 容斥
  5. CreateMutex用法
  6. OSGi 系列(十四)之 Event Admin Service
  7. [转]关于docker包存储结构说明
  8. 【Unity】1.2 HelloWorld--测试桌面和Android游戏能否正常运行
  9. 《Linux多线程服务端编程——使用muduo C++网络库》读书笔记
  10. 基础的linux学习