python爬取网页信息时出现UnicodeEncodeError
作者:互联网
print( response.text)
UnicodeEncodeError: 'gbk' codec can't encode character '\xa9' in position 252144: illegal multibyte sequence
UnicodeEncodeError: ‘gbk’ codec can’t encode character ‘\xa9’ in position 11163: illegal multibyte sequence
此问题出现时先转码为GBK,在加上ignore参数,在解码为GBK即可解决
解决办法:
print( response.text.encode('gbk','ignore').decode('gbk'))
标签:sequence,python,text,gbk,GBK,爬取,UnicodeEncodeError,encode 来源: https://www.cnblogs.com/acheng1011/p/15881794.html