首页 > 其他 > 详细

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

时间:2017-04-08 14:06:35      阅读:471      评论:0      收藏:0      [点我收藏+]

 敏感词文件内容:

技术分享

 

代码:

def filtered_words(path=filtered_words.txt):
    words = []
    with open(path, r, encoding=utf-8, newline=‘‘) as f:
        for line in f:
            words.append(line.strip())
    return words

def main():
    words = filtered_words()
    while True:
        #注意 python3中input相当于python2中raw_input
        text = input(content: ).strip()
        if text in words:
            print(Freedom)
        else:
            print(Human Rights)

 

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

原文:http://www.cnblogs.com/hupeng1234/p/6681466.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!