UnicodeEncodeError: 'gbk' codec can't encode character 'ufeff' in position 0: i(
Posted weiwei2016
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UnicodeEncodeError: 'gbk' codec can't encode character 'ufeff' in position 0: i(相关的知识,希望对你有一定的参考价值。
代码
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: i(的主要内容,如果未能解决你的问题,请参考以下文章
UnicodeEncodeError: 'ascii' codec can't encode character u'u5929' in position 2(
UnicodeEncodeError: 'ascii' codec can't encode characters
UnicodeEncodeError: 'ascii' codec can't encode characters in
UnicodeEncodeError: 'gbk' codec can't encode character 'xbb' in position
UnicodeEncodeError: 'ascii' codec can't encode character...的解决方法
UnicodeEncodeError: 'gbk' codec can't encode character 'u25aa' in position 15: (