<分区>
我在解释器提示符下尝试了这段代码:
>>> x = 7
>>> if x > 5:
... print("five")
我收到此错误消息:
File "<stdin>", line 2
print("five")
IndentationError: expected an indented block
为什么?
标签 python
<分区>
我在解释器提示符下尝试了这段代码:
>>> x = 7
>>> if x > 5:
... print("five")
我收到此错误消息:
File "<stdin>", line 2
print("five")
IndentationError: expected an indented block
为什么?
最佳答案
在 shell 中你应该这样做:
>>> if x > 5:
... print("five")
即在“:”后面加一个缩进 block
关于Python Shell 需要一个缩进 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44503446/
相关文章:
python - 无需替换即可生成 numpy.random.choice 的二维数组
python - 创建交互变量的函数 : what is wrong with the code?
python - 用于匹配未被特定字符包围的字符的正则表达式模式
python - numpy.dot -> MemoryError, my_dot -> 非常慢,但有效。为什么?
Python:如何从文件中的一行中读取字符并将它们转换为 float 和字符串,具体取决于它们是数字还是字母?
python - 网页抓取代码中出现 JSON 错误,如何修复?