运行Python脚本报错:TabError: inconsistent use of tabs and spaces in indentation

已知问题,Python是以4个空格为缩进的,比如if里面的代码要比if那行要多4个空格缩进,if语句结束后,跳出if命令的代码和if所在行的缩进是一样的。

上面报错的问题是因为使用了Tab符号代替了4个空格

Python -- TabError: inconsistent use of tabs and spaces in indentation
图中1和2区域能看出明显区别。
1、使用了Tab,2、使用了4个空格。
如何查看,在Sublime编辑器中,全选内容,可以如上图所示。

解决办法:将1的Tab替换成4个空格就可以了。

相关文章:

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