Python Shell中预期的缩进块
问题描述:
>>> x = 7
>>> if x > 5:
...print("five")
//它说 文件 “”,2号线Python Shell中预期的缩进块
print("five")
IndentationError:预计缩进块
答
缩进是重要的Python编写的。您需要使用几个空格或标签缩进print
声明,否则解释器会认为您的if
为空。
+1
谢谢@MrPromethee –
+3
https://stackoverflow.com/help/someone-answers – phd
欢迎stackoverflow.com
也就是说,后面加一个缩进块。请花些时间阅读[帮助页面](http://stackoverflow.com/help),尤其是名为“[我可以在这里询问什么主题?](http://stackoverflow.com/help/on -topic)“和”[我应该避免询问什么类型的问题?](http://stackoverflow.com/help/dont-ask)“。也请[参观](http://stackoverflow.com/tour)并阅读[如何提出好问题](http://stackoverflow.com/help/how-to-ask)。最后,请学习如何创建[最小,完整和可验证示例](http://stackoverflow.com/help/mcve)。 – ArturFH