We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6c97b3d commit 40c5e11Copy full SHA for 40c5e11
2 files changed
vvzwvv/0012/0012.py
@@ -0,0 +1,22 @@
1
+from cmd import Cmd
2
+
3
+class CmdCheck(Cmd):
4
5
+ def __init__(self):
6
+ Cmd.__init__(self)
7
+ self.intro = "-------- Word Sensor (Input \"exit\" for termination) --------"
8
+ self.prompt = "> "
9
+ self.sensitive = map(lambda word: word.strip("\n"), open("filtered_words.txt").readlines())
10
11
+ def default(self, line):
12
+ for word in self.sensitive:
13
+ if word in line:
14
+ line = line.replace(word, ''.join("*" for i in range(len(word))))
15
+ print line
16
17
+ def do_exit(self, line):
18
+ exit()
19
20
+if __name__ == "__main__":
21
+ cmd = CmdCheck()
22
+ cmd.cmdloop()
vvzwvv/0012/filtered_words.txt
@@ -0,0 +1,11 @@
+北京
+程序员
+公务员
+领导
+牛比
+牛逼
+你娘
+你妈
+love
+sex
+jiangge
0 commit comments