首页 > 解决方案 > 如何将 python3 用于 profantiy 编辑器迷你项目?

问题描述

[This is the error output.][1]I've tried using urllib.parse also to parse the value but nothing helps.Please help me out. I'm a beginner in Python.

    import urllib.request

    def text_finder():
        songs=open("C:\song.txt")
        contents=songs.read()
        songs.close()
        profanity(contents)

    def profanity(text_to_check):    
        connection=urllib.request.urlopen("http://www.wdylike.appspot.com/?q="+text_to_check)
        output=connection.read()
        connection.close()
        if "true" in output:
            print("No curse word in text.")
        elif "false" in output:
            print("There is curse word in your text!")
        else:
            print("Something went wrong!")

    text_finder()

这是错误消息输出。请帮帮我。重新启动:C:\Users\simra\AppData\Local\Programs\Python\Python37-32\profanityeditor.py 回溯(最近一次调用):文件“C:\Users\simra\AppData\Local\Programs\Python\Python37 -32\profanityeditor.py”,第 18 行,在 text_finder() 文件“C:\Users\simra\AppData\Local\Programs\Python\Python37-32\profanityeditor.py”,第 6 行,在 text_finder 亵渎(内容)中文件“C:\Users\simra\AppData\Local\Programs\Python\Python37-32\profanityeditor.py”,第 9 行,亵渎连接=urllib.request.urlopen(" http://www.wdylike.appspot。 com/?q="+text_to_check) 文件 "C:\Users\simra\AppData\Local\Programs\Python\Python37-32\lib\urllib\request.py",第 222 行,在 urlopen 返回 opener.open(url, data, timeout)文件“C:\Users\simra\AppData\Local\Programs\Python\Python37-32\lib\urllib\request.py”,第 531 行,打开响应 = meth(req, response) 文件“C:\Users\ simra\AppData\Local\Programs\Python\Python37-32\lib\urllib\request.py",第 641 行,在 http_response 'http'、请求、响应、代码、msg、hdrs) 文件“C:\Users\simra \AppData\Local\Programs\Python\Python37-32\lib\urllib\request.py”,第 569 行,错误返回 self._call_chain(*args) 文件“C:\Users\simra\AppData\Local\Programs\ Python\Python37-32\lib\urllib\request.py”,第 503 行,在 _call_chain 结果 = func(*args) 文件“C:\Users\simra\AppData\Local\Programs\Python\Python37-32\lib\urllib\request.py”,第 649 行,在 http_error_default 中引发 HTTPError(req.full_url , 代码, msg, hdrs, fp) urllib.error.HTTPError: HTTP 错误 404: 未找到

标签: pythonhttphttp-status-code-404

解决方案


推荐阅读