python development environment PyScripter Chinese garbled code problem solution

  • 2020-05-10 18:23:11
  • OfStack

PyScripter looks like a pretty good python ide

Environment:

PyScripter 2.6.0.0

python3.4

Question:

PyScripter has a small hole. When you open the file, the Chinese characters are all scrambled. The new file Chinese in PyScripter can be displayed normally, but when it is re-opened, the Chinese characters are scrambled.

PyScripter Chinese garbled reason:

The reason is that if the file header does not have an encoding declaration, PyScripter will open the file using ANSI by default.

The default PyScripter file template also has no encoding declaration, and the time to reopen the file is not opened as UTF-8, so it is scrambled.

Solutions:

1. Open the file with another editor, add this 1 line declaration and save:

# -*- coding: UTF-8 -*-

2. Modify the PyScripter file template and add this line as well:

# -*- coding: UTF-8 -*-

This will automatically bring this line of code declaration with you every time you use PyScripter to create a new python code file. Very is very 10 minutes convenient.

Specific steps: tools → options → file template → python script → then add the encoding declaration in the template:

# -*- coding: UTF-8 -*-

→ click update!! ← this step is very important. Remember to update it before saving it.

All PyScripter configuration is saved in PyScripter.ini from your user directory /AppData\Roaming\PyScripter/ PyScripter.ini

C:\Users\Administrator\AppData\Roaming\PyScripter


Related articles: