[英]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.用 AutoPep8 打开了一张票,但是当我安装了 autopep8 扩展时,它似乎没有找到该模块。 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 https://github.com/hhatto/autopep8/issues/349#issuecomment-335662565
Install the below python packages for Python Code Format supporting in Windows为 Windows 中支持的 Python 代码格式安装以下 python 包
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.成功安装软件包后,在 vs code 中打开代码 -> 按 Ctrl + A 和 Ctrl + K,它将格式化代码。
autopep8 is listed as a requirement. autopep8 被列为一项要求。 On mac, using brew, you can install it as follows:在mac上,使用brew,可以如下安装:
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.然后在保存时打开vscode中的自动格式化选项,并将vscode设置中的python格式提供程序修改为黑色。 enjoy the black.享受黑色。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.