当我解析urllib时,我得到了一个UnicodeEncodeError。以下是我的代码。
import urllib.request, urllib.parse, urllib.error
def read_test():
quotes = open("C:\\movie_quotes.txt")
contents_of_file = quotes.read()
print(contents_of_file)
quotes.close()
check_profanity(contents_of_file)
def check_profanity(text_to_check):
connection = urllib.request.urlopen("http://www.wdylike.appspot.com/?q="+text_to_check)
output = connection.read()
print(output)
connection.close()
if __name__ == '__main__':
read_test()