首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Python AutoPep8格式不适用于最大行长度参数

Python AutoPep8格式不适用于最大行长度参数
EN

Stack Overflow用户
提问于 2020-08-08 18:41:55
回答 2查看 11.5K关注 0票数 6

我注意到一件奇怪的事情,当我们在VSCode中设置

代码语言:javascript
运行
复制
    "python.formatting.autopep8Args": [
        "--line-length 119"
    ],

但是,如果此设置处于默认模式,即行长度为79,则它工作得很好。是不是autopep8有什么问题,只能在79行的情况下工作,或者我在VSCode中犯了什么错误。我需要的主要特性是,当我的python程序行太长时,它应该能够将其分成多行。我不想继续使用79个字符的方法。我的首选方法是119个字符。目前,我必须手动缩进大行。除了支持119个字符并自动缩进超过119个字符的行的pep8之外,还有其他格式吗?

我附上了我的settings.json文件数据

代码语言:javascript
运行
复制
{
    "window.zoomLevel": 1,
    "python.dataScience.sendSelectionToInteractiveWindow": true,
    "diffEditor.ignoreTrimWhitespace": false,
    "editor.fontSize": 16,
    "python.formatting.provider": "autopep8",
    "editor.formatOnPaste": true,
    "editor.formatOnSave": true,
    "editor.formatOnType": true,
    "python.autoComplete.addBrackets": true,
    "python.formatting.autopep8Args": [
        "--line-length 119"
    ],
    // "python.linting.flake8Args": [
    //     "--max-line-length=120"
    // ],
    "files.autoSaveDelay": 10000,
    "editor.defaultFormatter": "ms-python.python",
    "files.autoSave": "afterDelay",
    "files.trimTrailingWhitespace": true,
    "files.trimFinalNewlines": true,
    "editor.quickSuggestions": true,
    "editor.codeActionsOnSave": null,
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-08-15 14:28:25

试验性的对我很有效

代码语言:javascript
运行
复制
"python.formatting.autopep8Args": ["--max-line-length", "120", "--experimental"]

check out this link for proper format specifier settings

票数 25
EN

Stack Overflow用户

发布于 2020-08-18 15:25:56

这应该行得通-

代码语言:javascript
运行
复制
"python.formatting.provider": "autopep8",
"python.formatting.autopep8Args": [
    "--max-line-length",
    "120",
    "--experimental"
]
票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63314452

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档