We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 189e3f2 commit 2078e16Copy full SHA for 2078e16
1 file changed
Drake-Z/0011/0011.py
@@ -0,0 +1,22 @@
1
+#!/usr/bin/env python3
2
+# -*- coding: utf-8 -*-
3
+
4
+'第 0011 题: 敏感词文本文件 filtered_words.txt,里面的内容为以下内容,当用户输入敏感词语时,则打印出 Freedom,否则打印出 Human Rights。'
5
6
+__author__ = 'Drake-Z'
7
8
+import os
9
+import re
10
11
+def filter_word(a):
12
13
+ f = open('filtered_words.txt', 'r', encoding = 'utf-8').read()
14
+ if a == '':
15
+ print('Human Rights !')
16
+ elif len(re.findall(r'%s' % (a), f)) == 0:
17
+ print('Human Rights !') #非敏感词时,则打印出 Human Rights !
18
+ else:
19
+ print('Freedom !') #输入敏感词语打印出 Freedom !
20
21
+z = input('请输入词语:')
22
+filter_word(z)
0 commit comments