Auto formatting Python in VS code

Installing Black:

Create a new environment with Conda:

conda create --name myenv python=3.8

Install Black with pip3:

pip3 install black

Editing the config for VSCode:

Opening the VSCode editor and switching to "myenv".

To config current project, we need to edit .vscode/settings.json.

Auto formatting the code with black when you save the changes:

"editor.formatOnSave": true,
"python.formatting.provider": "black",

留言

熱門文章