python中出现IndentationError:unindent does not match any outer indentation level

python中出现IndentationError:unindent does not match any outer indentation level

python中出现IndentationError:unindent does not match any outer indentation level

对于此错误,最常见的原因是,的确没有缩进。根据错误提示的行数,去代码中看了下,看起来没有什么问题呀,都有缩进,而且语法也没有错误呀。

python中出现IndentationError:unindent does not match any outer indentation level

当前用的文本编辑器Notepad++,有个设置,可以显示所有的字符的。 
在: 
视图 –> 显示符号 –> 显示空格与制表符 
这样就可以看到我们Python代码的到底有没有该缩进的都缩进了。

python中出现IndentationError:unindent does not match any outer indentation level

最终发现代码报错原因还真是出在这里,错误提示的这行看起来是缩进了,实际上确没有缩进,这就是问题的根源所在。