python常见编译错误:IndentationError缩进错误
来源:互联网 发布:美国失业金数据公布 编辑:程序博客网 时间:2024/06/05 09:20
Python语言是一款对缩进非常敏感的语言,最长见的编译错误莫过于tab和空格的混用,或者缩进不对所产生的错误,这些错误是很难用肉眼来辨别的。
在编译时会出现这样的错误:IndentationError:expected an indented block 说明此处需要缩进,你只要在出现错误的那一行,按空格或Tab(但不能混用)键缩进就行。(如果上一行以“:”结尾,那么下一行需要空格缩进)
因为第二行的for顶格写(没用缩进),果断报错IndentationError(缩进错误)了.在for前面加一个空格,就没什么问题了
需要说明的是,这个缩进可以用一个或多个空格来完成,建议最好依次用一个空格来缩进,因为你这一行缩进后,如果下一行仍然需要缩进,那么你就得在当前行缩进的基础上,再进行额外的缩进才行,具体说来就是当前行是从第5列开始的,那么下一行进行缩进的话,就得在第5列的基础上,再进行缩进。看下图:
第三行报错:IndentationError: unindent does not match any outer indentation level ,因为没有在第二行缩进的基础上进行缩进。下图是缩进后的代码:
0 0
- python常见编译错误:IndentationError缩进错误
- Python常见的缩进错误IndentationError: unexpected indent
- Python常见错误:ImportError、UnicodeEncodeError、IndentationError
- python常见错误:IndentationError: unexpected indent
- python错误之IndentationError
- Python编译时提示错误 IndentationError: unexpected indent
- 【缩进错误】Python脚本运行出现语法错误:IndentationError: unindent does not match any outer indentation level
- 【Python】关于递进错误indentationerror
- python错误:IndentationError: unexpected indent
- Python错误IndentationError: unexpected indent
- Python之缩进错误
- Python编程错误之IndentationError: unexpected indent
- python错误:IndentationError:expected an indented block
- Python 错误:IndentationError: expected an indented block
- Python错误:IndentationError: expected an indented block
- Python程序编译运行出现错误:IndentationError: unindent does not match any outer indentation level
- python3.4 编译时提示错误 IndentationError: unexpected indent
- python3.4 编译时提示错误 IndentationError: unexpected indent
- c++常量头文件的书写
- Ubuntu 下配置使用Android adb
- 软件文档的概念和细分
- 屏幕适配
- Codeforces Round #328 D Super M(树的直径+树形DP)
- python常见编译错误:IndentationError缩进错误
- 获得网络视频缩略图并且播放
- SQLite3的使用
- asp.net之简易聊天室
- Java线程池
- 用mysql的federated数据引擎和触发器实现跨服务器表数据同步
- ETS的配置
- iOS图片选择的优化与封装
- FMDB的使用