python 转码报错decoding Unicode is not supported

PythonUnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 937: ordinal not in range(128) Logged from file scraper.py,


u = unicode("辣", "utf-8")
unicode(u'foo', 'utf-8')
以上这种转码方式可能会报错,如果报错请使用一下这种,在字符串后面添加 encode("utf-8")


result = google.searchGoogle(param).encode("utf-8")


你可能感兴趣的:(Python)