UnicodeEncodeError: 'gbk' codec can't encode character '\ufeff' in positio
作者:互联网
代码
text = response.content.decode(encoding="utf-8")出现报错
提示UnicodeEncodeError: 'gbk' codec can't encode character '\ufeff' in position 0: illegal multibyte sequence
试过加ignore:
text = response.content.decode(encoding='gbk', errors='ignore')
依然报错,百度查询到了解决方案:
response.content.decode(encoding="utf-8-sig")
这样就没问题了。
标签:decode,encoding,illegal,ufeff,multibyte,gbk,content,报错,response 来源: https://www.cnblogs.com/weiwei2016/p/10449769.html