UnicodeEncodeError: 'gbk' codec can't encode character '\xbb' in position 29802: illegal multibyte
文章图片
上面这段代码会报:UnicodeEncodeError: 'gbk' codec can't encode character '\xbb' in position 29802: illegal multibyte sequence
文章图片
错误的原因是with没有指定编码格式。指定为utf-8格式就好了。
with open('header.html', "w", encoding="utf-8")as f:
【UnicodeEncodeError: 'gbk' codec can't encode character '\xbb' in position 29802: illegal multibyte】
推荐阅读
- FreeCodeCamp-JavaScript初级算法题-3
- FreeCodeCamp-JavaScript初级算法题-2
- FreeCodeCamp-JavaScript初级算法题-1
- Jboss|Jboss .netty项目使用的netty包详解之 org.jboss.netty.handler.codec.base64
- latex 公式转图片
- [Image_Codec]常见图片格式的封装及编解码-Android平台(一)BMP
- Python|Python codecademy student Becomes the Teacher 9.How is Everybody doing?
- window下pip安装模块报错(‘utf-8‘ codec can‘t decode byte 0xd5 in position 18: invalid continuation byte)
- .net6环境下使用RestSharp请求GBK编码网页乱码的解决方案
- 解决Python:UnicodeDecodeError:‘utf-8‘ codec can‘t decode byte 0xe5 in position 1797: invalid continuat