我在python 3.5中有以下代碼。在python中打開Url的錯誤
import urllib.request
prof_list = open(r"C:\local\profanity.txt")
contents = prof_list.read()
connect = urllib.request.urlopen("http://wdyl.com/profanity?q="+contents)
output = connect.read()
connect.close()
prof_list.close()
當我運行的代碼,我得到
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
雖經多方努力,未能身影。
是什麼profanity.txt的內容? –