【缩进错误】Python脚本运行出现语法错误:IndentationError: unindent does not match any outer indentation level
2017-01-09 10:15
671 查看
这种情况一般是把tab键和空格键弄混了。所以在编辑的时候,不管是从别的地方粘贴过来还是自己写,都一定要坚持用空格键,这样能减少错误。
so和一些网友给出的如下的解释和解决方法:
so:http://stackoverflow.com/questions/492387/indentationerror-unindent-does-not-match-any-outer-indentation-level
某博客:
一个Python脚本,本来都运行好好的,然后写了几行代码,而且也都确保每行都对齐了,但是运行的时候,却出现语法错误:
IndentationError: unindent does not match any outer indentation level
【解决过程】
1.对于此错误,最常见的原因是,的确没有对齐。但是我根据错误提示的行数,去代码中看了下,没啥问题啊。
都是用TAB键,对齐好了的,没有不对齐的行数啊。
2.以为是前面的注释的内容影响后面的语句的语法了,所以把前面的注释也删除了。
结果还是此语法错误。
3.后来折腾了半天,突然想到了,把当前python脚本的所有字符都显示出来看看有没有啥特殊的字符。
当前用的文本编辑器Notepad++,好像有个设置,可以显示所有的字符的。
找到了,在:
视图 -> 显示符号 -> 显示空格与制表符
so和一些网友给出的如下的解释和解决方法:
so:http://stackoverflow.com/questions/492387/indentationerror-unindent-does-not-match-any-outer-indentation-level
某博客:
一个Python脚本,本来都运行好好的,然后写了几行代码,而且也都确保每行都对齐了,但是运行的时候,却出现语法错误:
IndentationError: unindent does not match any outer indentation level
【解决过程】
1.对于此错误,最常见的原因是,的确没有对齐。但是我根据错误提示的行数,去代码中看了下,没啥问题啊。
都是用TAB键,对齐好了的,没有不对齐的行数啊。
2.以为是前面的注释的内容影响后面的语句的语法了,所以把前面的注释也删除了。
结果还是此语法错误。
3.后来折腾了半天,突然想到了,把当前python脚本的所有字符都显示出来看看有没有啥特殊的字符。
当前用的文本编辑器Notepad++,好像有个设置,可以显示所有的字符的。
找到了,在:
视图 -> 显示符号 -> 显示空格与制表符
相关文章推荐
- [解决方案]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
- 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
- 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
- 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问题系列--2】脚本运行出现语法错误: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
- Python脚本运行出现语法错误:IndentationError: unindent does not match any outer indentation level