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

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

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

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

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

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

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

添加for循环内容即可。

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

 

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

例如:

try与for在同一级别。

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

缩进之后就没有报错了。

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

 

相关文章:

  • 2021-04-02
  • 2021-08-30
  • 2022-12-23
  • 2022-12-23
  • 2021-09-26
  • 2021-10-21
  • 2021-06-12
猜你喜欢
  • 2021-10-18
  • 2022-12-23
  • 2022-12-23
  • 2021-08-25
  • 2021-11-24
  • 2021-06-02
相关资源
相似解决方案