python - Pycharm TabError : inconsistent use of tabs and spaces in indentation

标签 python pycharm

在 Pycharm 中我不断遇到此错误:

TabError: inconsistent use of tabs and spaces in indentation

我知道这是制表符/空格的问题。

我想要:

if len(myresults)==0:
    print("TEST")

每当我输入时,在我实际输入的每一行后按 Enter:

if len(myresults)==0:
        print("TEST")

导致此错误。我如何解决它?这是我对 pycharm 的设置:

Pycharm Settings

我可能错过了一些明显的东西,但我就是找不到它。

最佳答案

尝试,

  1. 在“设置 | 编辑器 | 代码样式”中,尝试禁用“检测并使用现有文件缩进进行编辑”,以防万一您启用了该功能(默认情况下)。注意:可能需要在编辑器中重新打开文件。
  2. 该文件路径中的任何位置是否有 .editorconfig 文件? .editorconfig 中的设置优先于(将覆盖)您的 IDE 设置。

关于python - Pycharm TabError : inconsistent use of tabs and spaces in indentation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53264075/

相关文章:

python - django send_mail 来自查询集

python - peewee实例匹配查询不存在

python - 为什么 Pycharm 不知道将哪些参数传递给继承的 Python 数据类 __init__?

python - django中是否有一个字段可以有多个外键字段?

python - Redis线程解释

python - 在 PyCharm 中使用 Vue.js 时出现 "Unidentified character <"错误

pycharm - PyCharm 中文件名旁边的数字是什么意思?

python - 在 PyCharm 中以拆分模式查看运行

python - Pycharm 无法连接到控制台进程

python - 如何从 corr() 函数输出中删除 NaN 值