第 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 '' 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()

小程序

 

TAG标签: 微信小程序微信敏感词

http://www.xiaochengxub.com/read-106007.html