python编程出现:expected an indented block错误。

python编程出现:expected an indented block错误。

expected an indented block翻译为:应为缩进块。

python中没有像C语言使用{}来表示从属关系,而是使用缩进表示上下级关系。

导致excepted an indented block这个错误的原因一般有两个:

1, 冒号后面是要写上一定的内容的。

例如:for循环后面不写任何代码,会出现:

添加for循环内容即可。

2,缩进不规范,少些或多些了一个空格。

例如:

try与for在同一级别。

缩进之后就没有报错了。

猜你喜欢

转载自www.cnblogs.com/ming-4/p/10260693.html
今日推荐