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

本文详细解析了Python中常见的IndentationError错误,该错误通常由不正确的缩进引起,例如混合使用Tab和空格。文章提供了具体的代码示例并解释了如何通过统一使用空格或Tab进行缩进来解决这一问题。

转载地址:https://blog.youkuaiyun.com/qq_15437667/article/details/52558999

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

Python语言是一款对缩进非常敏感的语言,最常见的情况是tab和空格的混用会导致错误,或者缩进不对。

1 >>> a=100
2 >>> if a>=0:
3 ... print a
4   File "<stdin>", line 2
5     print a
6         ^
7 IndentationError: expected an indented block

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

>>> a=100
>>> if a>=0:
...     print a
... else:
...     print -a
...
100

转载于:https://www.cnblogs.com/liangbo-1024/p/9232536.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值