Pycharm tips -- filewacher+black automatic formatting

black is a python code formatting tool to ensure the consistency and readability of team collaboration code format

This is the github address

Open pycharm's perference —> file watchers

Click the + sign in the lower left corner to select python file
as shown in the picture

The program should be replaced with your own black address. Do not use the python in the system environment. Permission denied will appear. You can use the conda environment or other environments.

After pip install black, enter which black to see the executable path of black.
Then copy it to the program.
One thing to note is that Chinese may report an error, so add the encoding configuration in the environment variables, as shown in the figure.
Pycharm is very powerful, you can install some interesting plugins yourself, not limited to black. I will explore and share more in the future.
black turns all single quotes into double quotes. If you are not used to it, you can add -S to Arguments to avoid it.
If you don't like the black style, there is also Autopep8 that can be configured. The principle should be similar to this.

Guess you like

Origin blog.csdn.net/fanjialiang2401/article/details/82915871