vsc+python格式化配置

     Python编码风格指导(PEP8)要求每行代码不得超过80个字符。在VSCode中Pyhon常用代码检查工具是pylint和flake8,常用代码格式化工具是yapf、autopep8和black。
  针对代码过长导致格式化时自动换行,在vsc的setting.json中修改格式化工具的每行最大字符个数,下面是常用的配置参数。

```bash

    "editor.formatOnSave": true,
    "editor.formatOnPaste": true,
    "editor.formatOnType": true,
    "terminal.integrated.cursorBlinking": true,

        // yapf
    "python.formatting.provider": "yapf",
    "python.formatting.yapfArgs": [
        "--style",
        "{column_limit: 200}"
    ],
    // autopep8
    "python.formatting.provider": "autopep8",
    "python.formatting.autopep8Args": [
        "--max-line-length=200"
    ],
    // black
    "python.formatting.provider": "black",
    "python.formatting.blackArgs": [
        "--line-length",
        "200"
    ],

        // pylint
    "python.linting.pylintEnabled": true,
    // flake8
    "python.linting.flake8Enabled": true,
    "python.linting.flake8Args": [
        "--max-line-length=200"
    ],
```

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值