pycharm编码报错及解决

报错

UnicodeDecodeError: ‘utf-8’ codec can’t decode bytes in position 1022-1023: unexpected end of data

image-20240301094129969

报错信息内容翻译如下所示

编码解码错误:“utf-8”编解码器无法解码位置1022-1023中的字节:数据意外结束

解决

image-20240301094338683

点击报错的地方,跳转定位到报错的代码。

image-20240301094613854

把这一行代码改成

r = r.decode('utf-8','ignore')

image-20240301094500125