Visual Studio代码和Autopep8格式化程序

2024-05-19 01:50:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试将python格式化程序设置为autopep8。它安装正确,但在VSCode中从未作为格式化选项

"python.formatting.autopep8Path": "C:\\Users\\DawsonSchaffer\\AppData\\Roaming\\Python\\Python39\\Scripts\\autopep8.exe",
    "python.formatting.autopep8Args": [
        "--max-line-length",
        "160",
        "--aggressive",
        "--aggressive",
        "--in-place"
    ],
    "[python]": {
        "editor.defaultFormatter": "autopep8",
    },

enter image description here

我已经改变了所有的设置。但是我不知道该为autopep8放什么

"[python]": {
    "editor.defaultFormatter": "ms-python.python",
},

or

"[python]": {
    "editor.defaultFormatter": "autopep8",
},

此外,控制托盘中不提供autopep8

enter image description here

谢谢 道森


Tags: 程序选项scriptsvscoderoamingusersappdataeditor
1条回答
网友
1楼 · 发布于 2024-05-19 01:50:46

这是为了配置

  "[python]": {
    "editor.defaultFormatter": "ms-python.python"
  },

在settings.json中

您可以这样设置以应用autopep8格式:

"python.formatting.provider": "autopep8",
"editor.formatOnSave": true,
"files.autoSave": "afterDelay",

Related official docs

相关问题 更多 >

    热门问题