第 0011 题: 敏感词文本文件 filtered_words.txt,里面的内容为以下内容,当用户输入敏感词语时,则打印出 Freedom,否则打印出 Human Rights。

 

 1 #!/usr/bin/env python
 2 
 3 filtered = []
 4 
 5 def get_filtered_words():
 6     f = open('test.txt')
 7     for word in f.readlines():
 8         if '\n' in word:
 9             filtered.append(word[:-1])
10         else:
11             filtered.append(word)
12     print(filtered)
13 
14 def input_check():
15     while True:
16         text = input('请输入内容:')
17         if text in filtered:
18             print( 'Freedom')
19         else:
20             print('Human Rights')
21 
22 if __name__ == '__main__':
23     get_filtered_words()
24     input_check()

 

转载于:https://www.cnblogs.com/zyb993963526/p/8358374.html

Logo

网易易盾是国内领先的数字内容风控服务商,依托网易二十余年的先进技术和一线实践经验沉淀,为客户提供专业可靠的安全服务,涵盖内容安全、业务安全、应用安全、安全专家服务四大领域,全方位保障客户业务合规、稳健和安全运营。

更多推荐