简体   繁体   English

在 PyCharm 中返回后禁用自动导入

[英]Disable auto import after return in PyCharm

How to disable auto import when I return in my code当我返回我的代码时如何禁用自动导入

在此处输入图片说明

在此处输入图片说明

As shown in the diagram above,after I choose re.findall at row: 20. PyCharm will auto append "import \\ re" for me,I want to close that but I don`t know the method.如上图所示,当我在第 20 行选择re.findall ,PyCharm 会自动为我附加"import \\ re" ,我想关闭它但我不知道方法。

For Python auto-import can't be fully disabled in the current version of PyCharm, see Disable auto import.对于Python自动导入不能完全PyCharm的当前版本禁用,请参阅禁用自动导入 Only the import style and tooltip can be adjusted, see Automatically add import statements.只有进口的风格和工具提示可以调整,看自动添加import语句

The example in the question with a line break is not typical, one possible reason for this is the file extension being .config and not .py .问题中带有换行符的示例并不典型,一个可能的原因是文件扩展名是.config而不是.py

import \
    re

What is happening is the line is being wrapped, a combination of several settings can cause this.发生的情况是线路被换行,几种设置的组合可能会导致这种情况。 Go to File > Settings > Editor > Code Style > Python > Wrapping and Braces .转到File > Settings > Editor > Code Style > Python > Wrapping and Braces If the first option Hard wrap at: is set to a high value (eg 120) then confirm the option in "From" Import Statements is Do not Warp .如果第一个选项Hard wrap at:设置为高值(例如 120),则确认"From" Import Statements的选项为Do not Warp See the screenshot:看截图:

在此处输入图片说明

One side-effect is that imports might not wrap automatically on longer lines.一个副作用是导入可能不会在更长的行上自动换行。 However, you can always refactor the code afterwards.但是,您可以随时重构代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM