UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc7 in position 0: invalid continuation byte

【写在前面】

今天在做说stm32和服务器之间的通信时因为编码格式问题导致了一些错误做个记录;
测试时搭载在云服务器上的python socket通讯模块数据接收部分代码如下:

 receive_data = serObj.recv(1024).decode('utf-8')

运行下来直接报错:
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xc7 in position 0: invalid continuation byte

【解决方案】

- 把编码方式utf-8 修改为gb18030

【测试结果】

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_44322778/article/details/106083194