Python Shell 需要一个缩进块

piz*_*blo 4 python

我在解释器提示符下尝试了这段代码:

>>> x = 7
>>> if x > 5:
... print("five")
Run Code Online (Sandbox Code Playgroud)

我收到此错误消息:

File "<stdin>", line 2
    print("five") 
IndentationError: expected an indented block
Run Code Online (Sandbox Code Playgroud)

为什么?

Dar*_*nus 9

在 shell 中你应该这样做:

>>> if x > 5:
...    print("five")
Run Code Online (Sandbox Code Playgroud)

即在“:”后面添加一个缩进块