Skip to content

Commit 40c5e11

Browse files
committed
Problem 0012 solved
1 parent 6c97b3d commit 40c5e11

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

vvzwvv/0012/0012.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
北京
2+
程序员
3+
公务员
4+
领导
5+
牛比
6+
牛逼
7+
你娘
8+
你妈
9+
love
10+
sex
11+
jiangge

0 commit comments

Comments
 (0)