如何修复python中围绕elif的语法错误?
我无法理解python中的这个语法错误如何修复python中围绕elif的语法错误?,python,windows,syntax-error,Python,Windows,Syntax Error,我无法理解python中的这个语法错误 #I typed this... elif self.x > 0: if self.y != 0: self.game.canvas.itemconfig(self.image, \ image=self.images_right[2]) 当这个代码被输入时,我得到 Traceback (most recent call back):
#I typed this...
elif self.x > 0:
if self.y != 0:
self.game.canvas.itemconfig(self.image, \
image=self.images_right[2])
当这个代码被输入时,我得到
Traceback (most recent call back):
File "<pyshell#12>",line 245, in <module>
elif self.x > 0:
SyntaxError: invalid syntax
回溯(最近的回拨):
文件“”,第245行,在
elif self.x>0:
SyntaxError:无效语法
我以各种方式缩进,但这并不能解决问题。
elif
仅在您之前有适当的if
时有效,例如:
if self.x < 0:
pass
elif self.x > 0:
...
如果self.x<0:
通过
elif self.x>0:
...
似乎您错过了这里的
if
。我只显示了部分代码,实际上我在之前添加了if。请更新问题以显示完整的if
子句。我在您的问题中看不到这一点。所以我唯一能做的就是猜测。请更新问题以显示完整的if
子句。我在你的问题中看不到这一点。所以我唯一能做的就是猜测。