python学习:IndentationError:expected an indented block错误解决

Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的Python程序员,也可能陷入陷阱当中。最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分别的。

在编译时会出现这样的错IndentationError:expected an indented block说明此处需要缩进,你只要在出现错误的那一行,按空格或Tab(但不能混用)键缩进就行。

往往有的人会疑问:我根本就没缩进怎么还是错,不对,该缩进的地方就要缩进,不缩进反而会出错,比如:

模式一:

#coding:utf-8

money=["张总","王总","李总","刘经理","保洁吴大妈","程序员的我"]

for man in money:

print man

print len(money)

运行结果:

D:\PF\Python> python test.py

File "test.py", line 7

print man

^

IndentationError: expected an indented block

模式二:

#coding:utf-8

money=["张总","王总","李总","刘经理","保洁吴大妈","程序员的我"]

for man in money:

print man

print len(money)

运行结果

D:\PF\Python> python test.py

张总

6

王总

6

李总

6

刘经理

6

保洁吴大妈

6

程序员的我

6

模式三:

#coding:utf-8

money=["张总","王总","李总","刘经理","保洁吴大妈","程序员的我"]

for man in money:

print man

print len(money)

运行结果:

D:\PF\Python> python test.py

张总

王总

李总

刘经理

保洁吴大妈

程序员的我

6

时间: 2024-08-13 11:07:38

python学习:IndentationError:expected an indented block错误解决的相关文章

python问题:IndentationError:expected an indented block错误解决《转》

python问题:IndentationError:expected an indented block错误解决 标签: python语言 2012-07-07 17:59 125145人阅读 评论(9) 收藏 举报  分类: python学习笔记(2)  原文地址:http://hi.baidu.com/delinx/item/1789d38eafd358d05e0ec1df Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的Python程序员,也可能陷入陷阱

python问题:IndentationError:expected an indented block错误解决

Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的Python程序员,也可能陷入陷阱当中.最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分别的. 在编译时会出现这样的错IndentationError:expected an indented block说明此处需要缩进,你只要在出现错误的那一行,按空格或Tab(但不能混用)键缩进就行. 往往有的人会疑问:我根本就没缩进怎么还是错,不对,该缩进的地方就要缩进,不缩进反而会出错,,比如:

IndentationError:expected an indented block错误解决

Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的Python程序员,也可能陷入陷阱当中.最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分别的. 在编译时会出现这样的错IndentationError:expected an indented block说明此处需要缩进,你只要在出现错误的那一行,按空格或Tab(但不能混用)键缩进就行. 往往有的人会疑问:我根本就没缩进怎么还是错,不对,该缩进的地方就要缩进,不缩进反而会出错,,比如:

python问题:IndentationError:expected an indented block错误

Python语言是一款对缩进非常敏感的语言,最常见的情况是tab和空格的混用会导致错误,或者缩进不对. >>> a=100>>> if a>=0:... print a File "<stdin>", line 2 print a ^IndentationError: expected an indented block1234567在编译时会出现这样的错IndentationError:expected an indented b

IndentationError: expected an indented block错误

Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的python程序员,也可能陷入陷阱当中.最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分别的. 在编译时会出现这样的错IndentationError:expected an indented block说明此处需要缩进,你只要在出现错误的那一行,按空格或Tab(但不能混用)键缩进就行. 往往有的人会疑问:我根本就没缩进怎么还是错,不对,该缩进的地方就要缩进,不缩进反而会出错,,比如:

IndentationError: expected an indented block

print前面要加一个Tab Python对缩进非常严格

python问题:IndentationError:expected an indented blo

Python语言是一款对缩进非常敏感的语言,给很多初学者带来了困惑,即便是很有经验的Python程序员,也可能陷入陷阱当中.最常见的情况是tab和空格的混用会导致错误,或者缩进不对,而这是用肉眼无法分别的. 在编译时会出现这样的错IndentationError:expected an indented block说明此处需要缩进,你只要在出现错误的那一行,按空格或Tab(但不能混用)键缩进就行. 往往有的人会疑问:我根本就没缩进怎么还是错,不对,该缩进的地方就要缩进,不缩进反而会出错,,比如:

python学习笔记系列----(六)错误和异常

python至少有2类不同的错误:语法错误(Syntax Errors)和异常(Exceptions). 8.1 语法错误 这个单词应该还是很有必要认识的,呵呵,语法错误,也叫解析错误,是我们最不愿意发生的错误,直接拿官网的例子: >>> while True print 'Hello world' File "<stdin>", line 1, in ? while True print 'Hello world' ^ SyntaxError: inva

MFC出现 error RC2108: expected numerical dialog constant错误解决办法

MFC在使用picture console控件之后往往会弹出这个错误:error RC2108: expected numerical dialog constant. 此时,双击这个错误,会跳到提示错误的那一行,在那一行中的一串地址前插入:"Static", SS_BITMAP,