How do you format python code in Visual Studio Code?

Dan Quackenbush picture Dan Quackenbush · Oct 11, 2017 · Viewed 16.9k times · Source

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

Answer

Dhandapani Sudhakar picture Dhandapani Sudhakar · Mar 27, 2020

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.