Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何修复python中围绕elif的语法错误?_Python_Windows_Syntax Error - Fatal编程技术网

如何修复python中围绕elif的语法错误?

如何修复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):

我无法理解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):
    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
子句。我在你的问题中看不到这一点。所以我唯一能做的就是猜测。