【问题标题】:The Black Formatter - Python黑色格式化程序 - Python
【发布时间】:2020-10-26 00:10:25
【问题描述】:

我刚开始在 VSCode 中使用 Black Formatter 模块,一切都很顺利,直到我注意到它使用双引号而不是我已经在我的代码中使用的单引号......它覆盖了它......

那么,我可以在 VSCode 中添加一个黑色参数来解决这个问题吗?

谢谢。

【问题讨论】:

  • 相关文档中没有提到吗?
  • 不,我没在那里找到它

标签: python python-black


【解决方案1】:

您可以在命令行或 VSCode 选项中使用 --skip-string-normalization 选项。

请看这里:https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#strings

例如:

{
    ...
    "python.formatting.provider": "black",
    "python.formatting.blackArgs": [
        "--skip-string-normalization",
        "--line-length",
        "100"
    ]
    ...
}

祝你好运!

【讨论】:

    【解决方案2】:

    --skip-string-normalization或简称-S

    {
        ...
    
        "python.formatting.blackArgs": [
            "-S"
        ],
        ...
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-16
      • 1970-01-01
      • 2022-06-30
      • 1970-01-01
      • 2023-03-08
      • 1970-01-01
      • 2020-02-23
      • 2021-08-09
      相关资源
      最近更新 更多