PyCharm debug报错:UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 1022-1023: unexpected end of data
作者:刘兴禄
日期:2023年12月30
在用PyCharm 2023 debug报下面的错误:
Traceback (most recent call last):
File "C:\Develop\PyCharm202303\PyCharm 2023.3\plugins\python\helpers\pydev\_pydevd_bundle\pydevd_comm.py", line 304, in _on_run
r = r.decode('utf-8')
^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 1022-1023: unexpected end of data
用下面的方法成功解决了:
点击上述位置,跳到下面的源码部分,如下:
将这里修改为:
r = r.decode('utf-8','ignore')
重启PyCharm就可以了。
报错的的原因是decode()方法的第二个参数errors 的默认值为严格(strict),可以将其修改为ignore
。