Current conclusion:
The encoding
of the converted
file is utf-8
->utf-8 big
->ansi
-> utf-8
. Reopen the file after each conversion.
After observing for a period of time, there is no such error.
When I use PyCharm to debug .py
files, the same
file sometimes has UnicodeDecodeError, sometimes it’s normal. My operating system is Windows 10, PyCharm version is 2020.3.3 Community edition.
The error is as follows:
Traceback (most recent call last):
File "D:\Program Files\JetBrains\PyCharm Community Edition 2020.3.3\plugins\python-ce\helpers\pydev\_pydevd_bundle\pydevd_comm.py", line 301, in _on_run
r = r.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 1022-1023: unexpected end of data
I tried to add the following code to the header of the file, but sometimes I still get an error, how to solve it?
#!/usr/bin/env Python
# coding=utf-8
I found another way to save as a UTF-8 document with Notepad. I tried it, but there are still errors sometimes.