热线电话:13121318867

登录
2021-03-26 阅读量: 460
python报错:IndentationError: expected an indented block

问:

python报错:IndentationError: expected an indented block

image.png


答:

这是因为if语句中的语法结构为:

if 条件:
条件为真(True)执行操作
else
条件为假(False)执行操作


上面的代码缺少 条件为真执行操作部分导致语法结构不完整报错,解决方法是当条件为真

不需要执行操作时,执行pass空语句,来保证语法结构的完整性,pass语句什么都没做,作

用是一个占位符

image.png

99.9374
0
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子