IndentationError:expected an indented block错误的解决办法
来源:互联网 发布:网络兼职刷信誉骗局 编辑:程序博客网 时间:2024/04/29 10:56
第一次写py文件,执行的时候老是出现IndentationError:expected an indented block这个错误,我还以为自己程序写的有问题,试了很多。
一般运行py文件要符合一下几个简单步骤:
#!/usr/bin/env python#注意上面这一行必须是第一行顶头写。# python file example. # assume we name this file as "hello.py"# use shell command "chmod +x hello.py" to make this file executable. # then you are able to run it by typing "./hello.py"print "Hello this is from python!"
Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的Python程序员,也可能陷入陷阱当中。最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分别的。
在编译时会出现这样的错IndentationError:expected an indented block说明此处需要缩进,你只要在出现错误的那一行,按空格或Tab(但不能混用)键缩进就行。
往往有的人会疑问:我根本就没缩进怎么还是错,不对,该缩进的地方就要缩进,不缩进反而会出错,,比如:
if xxxxxx:(空格)xxxxx或者def xxxxxx:(空格)xxxxx还有for xxxxxx:(空格)xxxxx
一句话 有冒号的下一行往往要缩进,该缩进就缩进
- IndentationError:expected an indented block错误的解决办法
- IndentationError:expected an indented block错误解决
- IndentationError:expected an indented block错误
- IndentationError:expected an indented block错误解决
- IndentationError:expected an indented block错误解决
- IndentationError:expected an indented block错误解读
- IndentationError:expected an indented block错误解决
- IndentationError:expected an indented block错误解决
- 错误:IndentationError: expected an indented block
- python错误:IndentationError:expected an indented block
- IndentationError:expected an indented block错误解决
- Python 错误:IndentationError: expected an indented block
- Python错误:IndentationError: expected an indented block
- IndentationError:expected an indented block错误解决
- IndentationError:expected an indented block错误解决
- python中IndentationError: expected an indented block错误的解决方法
- IndentationError:expected an indented block
- IndentationError: expected an indented block
- 【黑马程序员】 java笔记——集合
- C++实现Python变量续
- magento的google站点地图的生成
- hdu acn 1028 Ignatius and the Princess III
- JAVA中实现多线程的两种方式
- IndentationError:expected an indented block错误的解决办法
- linux下 oracle 11g 手工建库
- 二分法查找
- C语言小知识--持续更新
- c#中关于结构体和字节数组转化
- Linux桌面管理工具
- C++基础学习系列第一部分——数组和指针
- java中的URLEncoder和URLDecoder类
- 高斯日记