The complete error message is shown below:
Not to read the error principle, but the solution is as follows:
Open the error file (pcacode.py in this case) using Notepad ++ (which is the editor I always use), find the encoding option in the menu bar, select UTF-8, save it, and run the Python code again so it doesn’t report any errors.
Not to read the error principle, but the solution is as follows:
Open the error file (pcacode.py in this case) using Notepad ++ (which is the editor I always use), find the encoding option in the menu bar, select UTF-8, save it, and run the Python code again so it doesn’t report any errors.
Another solution, which I haven’t tried, is the following:
import codecs
codecs.open('filename',encoding='uft-8')
Read More:
- When reading the CSV file with Python 3, the Unicode decodeerror: ‘UTF-8’ codec can’t decode byte 0xd0 in position 0: invalid con appears
- Python SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3:
- Unicode encodeerror encountered in Python 3
- python SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: trunca
- Pyinstall (Unicode error) ‘Unicode scape’ error handling
- Solve the problem of unable to locate package python3.6 when upgrading from python3.5 to python3.6 in ubantu16.04
- How to solve the problem of syntax error: (Unicode error)’unicodescape ‘codec can’t decode bytes in position 2-3: truncat
- Solution of Unicode decodeerror -‘utf-8 ‘codec can’t decode byte 0xc4 in position 0 – invalid continuation byte
- Can’t find Python executable “D:\python3\python.exe”, you can set the PYTHON env variable.
- Unicode encodeerror: ‘GBK’ codec can’t encode character solution
- scrapy:LookupError: unknown encoding: ‘unicode’
- 12304;388382;3906442nd 123057 SyntaxError and unicode error and 8216215;
- Solve the oserror: [errno 22] invalid argument: ‘u202ad’ in Python
- SyntaxError: (unicode error) ‘unicodeescape‘ codec can‘t decode bytes in position 2-3: truncated \UX
- Unicode decodeerror: ‘UTF-8’ codec can’t decode byte 0xd3 in position 238: invalid continuation B
- Successfully resolved Unicode decodeerror: ‘UTF-8’ codec can’t decode byte 0xd3 in position 238: invalid continuation B
- Unicode decodeerror: ‘UTF-8’ codec can’t decode byte 0x80 in position 3131: invalid start byte solution
- Solve the problem of prompt couldn’t find path to unrear library after installing unrear in Python
- Solve the problem of garbled code when Python connects to ADB
- The solution to the error of importing CSV from Python to Python