[Python]过滤脏话

[Python]过滤脏话,第1张

概述直接上代码↓fromosimportreadf='./Obscenity.txt'withopen(f,'r')asfi:l=fi.read().splitlines()fi.close()chat=str(input("请输入内容:"))foriinrange(len(l)):position=chat.find(l[i])ifposition==-1:

直接上代码↓

from os import readf='./Obscenity.txt'with open(f,'r') as fi:    l=fi.read().splitlines()    fi.close()chat=str(input("请输入内容:"))for i in range(len(l)):    position=chat.find(l[i])    if position==-1:        continue    else:        c=len(l[i])        chat=chat[0:position]+'*'*c+chat[position+c:len(chat)]print(chat)

然后那个.txt文件是这个内容↓

fuckcnmntmdnmwocrnm *** 你妈草泥马你他妈你tm *** 

记得这两个文件要放在同一目录下

总结

以上是内存溢出为你收集整理的[Python]过滤脏话全部内容,希望文章能够帮你解决[Python]过滤脏话所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/langs/1185328.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-03
下一篇2022-06-03

发表评论

登录后才能评论

评论列表(0条)

    保存