Python运行出现语法错误:IndentationError | TabError: 缩进错误排查

写了python代码,肉眼看没发现缩进错误啊,但是运行报缩进错误如下:


C:\Users\Administrator\Desktop>c:\Python34\python.exe dict.py

  File "dict.py", line 18

    continue

           ^

TabError: inconsistent use of tabs and spaces in indentation


C:\Users\Administrator\Desktop>



因为当前用的文本编辑器Notepad++,可以显示所有的字符的,在: 视图 -> 显示符号 -> 显示空格与制表符,就可以明确看到错误原因了

新的Python语法,是不支持的代码对齐中,混用TAB和空格的。所以出现上述错误提示了。

请把TAB改为空格即可!

参考博文:cnblogs.com/heimanba/p/3783022.html

IndentationError.png


猜你喜欢

转载自blog.51cto.com/8189171/2444147