简体   繁体   中英

How do you format python code in Visual Studio Code?

Opened a ticket with AutoPep8, but when I installed the autopep8 extension, it doesn't seem to find the module. When I change the config to tell it where it is a format doesn't do anything. Formating in terminal does however. Any ideas? https://github.com/hhatto/autopep8/issues/349#issuecomment-335662565

Install the below python packages for Python Code Format supporting in Windows

pip install autopep8

pip install pylint

Once you have successfully installed the packages, Open the code in vs code -> Press Ctrl + A and Ctrl + K, it will format the code.

autopep8 is listed as a requirement. On mac, using brew, you can install it as follows:

brew install autopep8

you should try black.

pip install black

and then open the auto format option in vscode when save and modify the python format provider to black in vscode settings. enjoy the black.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM