代码
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 '\ufeff' in position 0: illegal multibyte sequence
原文地址:https://www.cnblogs.com/weiwei2016/p/10449769.html
时间: 2024-10-05 04:56:53