UnicodeEncodeError: 'gbk' codec can't encode character '\ufeff' in position 0: illegal multibyte sequence
代码
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")
这样就没问题了。