UnicodeEncodeError:'ascii'编解码器无法对位置35中的字符'\ u2019'进行编码:序数不在范围内(128)

时间:2017-04-21 02:53:54

标签: python encoding utf-8 urllib

当我解析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()     

0 个答案:

没有答案