我需要在 Vs Code 中缩进我的 python 文件。我按照正常程序,
On Windows Shift + Alt + F On Mac Shift + Option + F On Linux Ctrl + Shift + I
但我的问题是每次我尝试格式化 python 文件时它都会说
Black does not support "Format Selection"
所以有人可以解释这里出了什么问题?
我的python版本是
Python 3.7.6
VS代码细节:
Version: 1.46.0 (user setup)
Commit: a5d1cc28bb5da32ec67e86cc50f84c67cc690321
Date: 2020-06-10T09:03:20.462Z
Electron: 7.3.1
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.18363
最佳答案
在我的情况下(在 VS 代码设置中选择 black
作为 Python 格式化提供程序),我遇到了此警告 每次我将一些文本粘贴到编辑器中时 .
以及VS Code的官方文档has a solution专门为它:
When using the black formatter, VS Code issues the following warning when pasting source code into the editor: Black does not support the "Format Select" command.
To prevent this warning, add the following entry to your user or workspace settings to disable format on paste for Python files:
"[python]": {
"editor.formatOnPaste": false
}
关于python - 黑色不支持 "Format Selection"命令 - VS Code 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62427817/