这是代码
GrassFilledX = GrassGenX
GrassFilledY = GrassGenY
GrassFillL = True
while GrassFillL == True:
if gx == hgx or hgx2:
while not crashed:
错误说
while not crashed:
^
IndentationError: expected an indented block
答案 0 :(得分:1)
Python期望在if
语句之后出现缩进块。
如果您想要空块,请使用pass
:
while GrassFillL == True:
if gx == hgx or hgx2:
pass
while not crashed:
这在其他语言中与一对空括号(例如if(condition){}
)具有相同的效果。在Python中,不允许将块保留为空,您必须至少在块中有一个NOP语句pass
,以使程序有效。
This是pass
的类似(但基本相同)的用例。