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

转载地址:https://blog.csdn.net/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

猜你喜欢

转载自www.cnblogs.com/liangbo-1024/p/9232536.html