我正在尝试做一个亵渎检查测试。到目前为止,我已经写的代码是使用urllib.request时出现HTTP错误
import urllib.request
def read_text():
file = open (r"C:\Users\Kashif\Downloads\abc.txt")
file_print = file.read()
print (file_print)
file.close()
check_profanity (file_print)
def check_profanity (file_print):
connection = urllib.request.urlopen ("http://www.purgomalum.com/service/containsprofanity?text="+file_print)
output = connection.read()
print ("The Output is "+output)
connection.close()
read_text()
,但我得到以下
urllib.error.HTTPError: HTTP Error 400: Bad Request
错误,我不知道,我错了。
我使用Python 3.6.1
您应该包括错误堆栈跟踪。 – Craicerjack
请同时包含abc的内容。文件本身可能存在一些问题。 –