美文网首页
菜鸟Python(4)

菜鸟Python(4)

作者: 有情绪的仙人掌 | 来源:发表于2017-08-26 13:46 被阅读13次

不好意思 这篇博客 由于需要第三方网站验证,暂时不可用

不敬语查询

# 定义一个读取的方法
def read_text():
    # 调用 open 内置函数打开文件
    quotes = open("E:\ButterKnife.txt")
    # 读取文件
    contents_of_file=quotes.read()
    print(contents_of_file)
    quotes.close()
read_text()

内置函数

Ptyhon 中的内置函数

利用代码访问网站

不敬语查询网站 可能需要进行科学上网,
利用这个网站后缀,进行查询是否存在不文明的字

import urllib
def read_text():
    quotes = open("E:\ButterKnife.txt")
    contents_of_file=quotes.read()
    print(contents_of_file)
    quotes.close()
    check_profanity(contents_of_file)
def check_profanity(check_text):
    connection=urllib.urlopen("http://www.wdylike.appspot.com/?q="+check_text)
    output=connection.read()
    print(output)
    connection.close()
read_text()

相关文章

网友评论

      本文标题:菜鸟Python(4)

      本文链接:https://www.haomeiwen.com/subject/hcwmdxtx.html