有时候从别人的代码里复制一大段到自己的编辑器时,或者从一个编辑器复制到另一个编辑器时总会莫名出现TabError: inconsistent use of tabs and spaces in indentation这样的错误,无论怎么重新输入都不起作用。
原因是 代码中有tab和空格混合使用的情况,只是你看不到


解决方法:

  • 1.如果是在subline text中TabError: inconsistent use of tabs and spaces in indentation解决
    TabError: inconsistent use of tabs and spaces in indentation解决在user那里加上

"draw_white_space": "all",

代码前就会显示空格和tab,把他们统一修改为tab就行,如果还是不行也可以复制没问题那些行的代码(复制时会把格式统一复制过来)再做修改。

TabError: inconsistent use of tabs and spaces in indentation解决

  • 如果是vscode
    可以在报错的那一行代码选中一整段代码,
    shift+tab整体左移后再Tab整体右移,
    这样代码就会自动调整格式,把多余的空格去除。
    此方法适用于大多数编辑器

TabError: inconsistent use of tabs and spaces in indentation解决
亲测有效
小白一个,如有错误欢迎指出哦!

相关文章:

  • 2021-08-17
  • 2021-09-06
  • 2021-09-12
  • 2021-11-22
  • 2021-06-13
  • 2021-07-12
  • 2021-07-10
  • 2021-04-26
猜你喜欢
  • 2022-01-13
  • 2021-06-04
  • 2021-06-04
  • 2021-07-23
  • 2021-05-06
相关资源
相似解决方案