Python:if语句出错

时间:2015-12-04 22:50:36

标签: python if-statement compiler-errors

start = end
  end = 450
  split = 413

for frameNum in range (start, end):  # frames 0 .. 9
  if frameNum <= split:
    space = makePicture(getMediaPath("space.jpg")) #1229 x 692 pixels 
    rocket = makePicture(getMediaPath("rocket1.png")) #74 x 139 pixels
    copyInto(rocket,space,614,553 - frameNum*2 + 2*start)
    writeFrame (frameNum, directory, space)
y = 553 - 2*split + 2*start   
  if frameNum > split:
    space = makePicture(getMediaPath("space.jpg")) #1229 x 692 pixels 
    rocket = makePicture(getMediaPath("rocketWOflames.jpg")) #74 x 139 pixels
    addOvalFilled (space, 150 + int(30*math.cos(1*frameNum/2)),150 + int(20*math.sin(1*frameNum/2)), 70, 30, red)
    copyInto(rocket,space,614,y)
    writeFrame (frameNum, directory, space)

我遇到麻烦的地方是“if frameNum&gt; split:”

以下是错误消息:

Invalid syntax
Your code contains at least one syntax error, meaning it is not legal jython.
The error is on line 94

我检查了缩进 - 看起来是正确的;我尝试用else替换if语句 - 没有用。谁能发现错误?

1 个答案:

答案 0 :(得分:1)

我想我已经为你清理过了。

end = 450
start = end
split = 413

for frameNum in range (start, end):  # frames 0 .. 9
    if frameNum <= split:
        space = makePicture(getMediaPath("space.jpg")) #1229 x 692 pixels 
        rocket = makePicture(getMediaPath("rocket1.png")) #74 x 139 pixels
        copyInto(rocket,space,614,553 - frameNum*2 + 2*start)
        writeFrame (frameNum, directory, space)
    y = 553 - 2*split + 2*start   
    if frameNum > split:
        space = makePicture(getMediaPath("space.jpg")) #1229 x 692 pixels 
        rocket = makePicture(getMediaPath("rocketWOflames.jpg")) #74 x 139 pixels
        addOvalFilled (space, 150 + int(30*math.cos(1*frameNum/2)),150 + int(20*math.sin(1*frameNum/2)), 70, 30, red)
        copyInto(rocket,space,614,y)
        writeFrame (frameNum, directory, space)