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")
这样就没问题了。
上一篇:解决UnicodeEncodeError: 'gbk' codec can't encode character u'\u25aa' in posi


下一篇:vim提示错误:E575: viminfo: Illegal starting char in line: ¿?(无效的启动字符)