Skip to content

Commit 2a37cbe

Browse files
committed
add
1 parent 64469e7 commit 2a37cbe

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

lwh/11/filter_word.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# coding = utf-8
2+
"""
3+
def filter_word():
4+
5+
# init
6+
filter_words_list = []
7+
with open("filtered_words.txt", "r") as f:
8+
string_read = f.readline()
9+
while string_read != "":
10+
filter_words_list.append(string_read)
11+
string_read = f.readline()
12+
13+
print("Enter \\q to exit.")
14+
string_input = input(
15+
"Input your word to check whether it was filtered ->")
16+
while string_input != "\\q":
17+
if string_input in filter_words_list:
18+
print("Freedom")
19+
else:
20+
print("Human Rights")
21+
string_input = input(
22+
"Input your word to check whether it was filtered ->")
23+
24+
if __name__ == "__main__":
25+
filter_word()
26+
27+
"""
28+
# coding = utf-8
29+
__author__ = 'Forec'
30+
word_filter = set()
31+
with open('filtered_words.txt',"r") as f:
32+
for x in f.readlines():
33+
word_filter |= {x.rstrip('\n')}
34+
while True:
35+
s = input()
36+
if s == 'exit':
37+
break
38+
elif s in word_filter:
39+
print('Freedom')
40+
else:
41+
print('Human Rights')
42+

lwh/11/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)