>>> def f(x):
... return x**2
File "<stdin>", line 2
return x**2
^
IndentationError: expected an indented block
这里是:
>>> def f(x):
... return x**2
...
>>> f(2)
4
Python缩进
缩进是指代码行开头的空格。
在其他编程语言中,代码中的缩进用于仅可读性,Python中的缩进非常重要。
Python使用缩进来表示代码块。
有关缩进的更多信息,请查看本教程。