<bdo id='dA43o'></bdo><ul id='dA43o'></ul>

    <i id='dA43o'><tr id='dA43o'><dt id='dA43o'><q id='dA43o'><span id='dA43o'><b id='dA43o'><form id='dA43o'><ins id='dA43o'></ins><ul id='dA43o'></ul><sub id='dA43o'></sub></form><legend id='dA43o'></legend><bdo id='dA43o'><pre id='dA43o'><center id='dA43o'></center></pre></bdo></b><th id='dA43o'></th></span></q></dt></tr></i><div id='dA43o'><tfoot id='dA43o'></tfoot><dl id='dA43o'><fieldset id='dA43o'></fieldset></dl></div>
  1. <legend id='dA43o'><style id='dA43o'><dir id='dA43o'><q id='dA43o'></q></dir></style></legend>
    1. <tfoot id='dA43o'></tfoot>

    2. <small id='dA43o'></small><noframes id='dA43o'>

      在 VSCode 中禁用 python 导入排序

      Disable python import sorting in VSCode(在 VSCode 中禁用 python 导入排序)

      <legend id='4L1eO'><style id='4L1eO'><dir id='4L1eO'><q id='4L1eO'></q></dir></style></legend>
              <tbody id='4L1eO'></tbody>

            <small id='4L1eO'></small><noframes id='4L1eO'>

                <bdo id='4L1eO'></bdo><ul id='4L1eO'></ul>
                <tfoot id='4L1eO'></tfoot>
                <i id='4L1eO'><tr id='4L1eO'><dt id='4L1eO'><q id='4L1eO'><span id='4L1eO'><b id='4L1eO'><form id='4L1eO'><ins id='4L1eO'></ins><ul id='4L1eO'></ul><sub id='4L1eO'></sub></form><legend id='4L1eO'></legend><bdo id='4L1eO'><pre id='4L1eO'><center id='4L1eO'></center></pre></bdo></b><th id='4L1eO'></th></span></q></dt></tr></i><div id='4L1eO'><tfoot id='4L1eO'></tfoot><dl id='4L1eO'><fieldset id='4L1eO'></fieldset></dl></div>

                本文介绍了在 VSCode 中禁用 python 导入排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我试图在保存文件时禁止 vscode 格式化我的 python 导入.我有一些代码必须在各种导入之间运行,所以顺序很重要,但每次我保存它时都会将导入推到顶部.

                I am trying to disable vscode from formatting my python imports when I save my file. I have some code that must run in between various imports so order is important, but every time I save it just shoves the imports to the top.

                我试着放了

                "editor.codeActionsOnSave": {
                    "source.organizeImports": false
                },
                

                在我的用户设置中,但这并不能解决问题.

                in my user settings but that doesn't fix it.

                谢谢!

                编辑-我想在保存时保持格式化,除了导入

                EDIT- I would like to keep formatting on save on except for the imports

                推荐答案

                检查 vscode 设置中的以下设置,如果是 true 则将其设置为 false 以完全禁用保存时格式化,如下所示:

                Check for the below setting in vscode settings, if it's true then set it to false for completely disabling formatting on save, like so :

                 "editor.formatOnSave": false
                

                为了格式化和忽略不在顶部的导入,首先将上述设置设为 true 并添加到您的用户设置中,然后尝试将此设置添加到您的用户设置中,如果您使用 python 的默认格式化程序,那就是 autopep8 :

                for formatting and to ignore imports not being at top itself, first make the above setting true and add to your user settings and try adding this setting to your user settings, if you're using the default formatter for python, that is autopep8 :

                "python.formatting.autopep8Args": ["--ignore","E402"]  
                

                其中E402表示模块级导入不在文件顶部"

                请注意,这仅在您使用默认格式化程序/linter 时才有效.如果您正在使用其他一些 linter,那么我建议您查看他们的文档以了解它是如何完成的.最常见的是可以使用全局配置文件,比如 $HOME/.config/.pycodestyle,并在那里添加必要的设置,例如:

                Note that this would only work if you are using the default formatter/linter. If you are using some other linter then i suggest you look up their documentation to see how it's done. Like most commonly one could make use of global config file, say $HOME/.config/.pycodestyle, and add necessary settings there, like :

                [pycodestyle]
                ignore = E402  
                

                格式化程序的参数应作为单独的列表项在引号中传递,例如 ["--ignore","E402"] 而不是 [--ignore=E402]

                这篇关于在 VSCode 中禁用 python 导入排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Kivy 1.9.0 Windows package KeyError: #39;rthooks#39;(Kivy 1.9.0 Windows 包 KeyError: rthooks)
                Python Kivy: how to call a function on button click?(Python Kivy:如何在按钮单击时调用函数?)
                How to disable a widget in Kivy?(如何禁用 Kivy 中的小部件?)
                Centering an object in Kivy(在 Kivy 中将对象居中)
                How to downgrade to Python 3.4 from 3.5(如何从 Python 3.5 降级到 Python 3.4)
                Change button or label text color in kivy(在kivy中更改按钮或标签文本颜色)

                1. <i id='QiDOU'><tr id='QiDOU'><dt id='QiDOU'><q id='QiDOU'><span id='QiDOU'><b id='QiDOU'><form id='QiDOU'><ins id='QiDOU'></ins><ul id='QiDOU'></ul><sub id='QiDOU'></sub></form><legend id='QiDOU'></legend><bdo id='QiDOU'><pre id='QiDOU'><center id='QiDOU'></center></pre></bdo></b><th id='QiDOU'></th></span></q></dt></tr></i><div id='QiDOU'><tfoot id='QiDOU'></tfoot><dl id='QiDOU'><fieldset id='QiDOU'></fieldset></dl></div>

                    • <legend id='QiDOU'><style id='QiDOU'><dir id='QiDOU'><q id='QiDOU'></q></dir></style></legend>

                        <tbody id='QiDOU'></tbody>

                      <small id='QiDOU'></small><noframes id='QiDOU'>

                      <tfoot id='QiDOU'></tfoot>

                          <bdo id='QiDOU'></bdo><ul id='QiDOU'></ul>