Skip to content

Commit 3ffa1f9

Browse files
committed
Finshed No.0011
Finished 0011 which is censor.py
1 parent e9769f5 commit 3ffa1f9

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

endersodium/0011/censor.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# coding:utf-8
2+
# Python Requriement:3(For Chinese Characters read purpose only)
3+
# Made by EnderSodium ender@enderself.co
4+
# 第 0011 题: 敏感词文本文件 filtered_words.txt,里面的内容为以下内容,当用户输入敏感词语时,则打印出 Freedom,否则打印出 Human Rights。
5+
6+
class filtered(object):
7+
# Read from txt file.
8+
def _init_(self):
9+
global filtered_words
10+
filtered_temp = open('filtered_words.txt','r')
11+
temp = filtered_temp.read()
12+
filtered_words = temp.split('\n')
13+
14+
def check(self,word):
15+
free = False
16+
for i in filtered_words:
17+
if word == i:
18+
print('Freedom')
19+
free = True
20+
break
21+
if free != True:
22+
print('Human Rights')
23+
24+
def main():
25+
# Assign Objects and initialize
26+
filtered_words_obj = filtered()
27+
filtered_words_obj._init_()
28+
# Read from user
29+
word = input('Please put in your word.')
30+
filtered_words_obj.check(word)
31+
32+
if __name__ == '__main__':
33+
main()

endersodium/0011/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)