其他分享
首页 > 其他分享> > UnicodeEncodeError: ‘gbk‘ codec can‘t encode character ‘\xa9‘ in position 6870: illegal multibyte s

UnicodeEncodeError: ‘gbk‘ codec can‘t encode character ‘\xa9‘ in position 6870: illegal multibyte s

作者:互联网

UnicodeEncodeError: ‘gbk’ codec can’t encode character ‘\xa9’ in position 6870: illegal multibyte sequence

解决方案 open()方法添加 encoding=“utf-8”,示例如下

with open('test.html', 'w', encoding='utf-8') as f:
    f.write(r.text)

标签:xa9,encoding,illegal,multibyte,character,codec,open,6870
来源: https://blog.csdn.net/qq_37077573/article/details/123146044