2016-01-31 61 views
0

嗨,我是新的Python和这是一个很多人都有的错误,但我不能帮助任何其他线程。代码是直接从这个tutorial。 它信息:[ERROR] behavior.box:FMBox :: createPythonModule:0 _Behavior__lastUploadedChoregrapheBehaviorbehavior_1291762048__root__headnod_1:用户类评估失败,错误: ( '预期的缩进块',( '',19,11,“motionProxy.angleInterpolation (名称,[0.0,1.0],时间真)\ n“))预计一个缩进块蟒蛇choregraphe

预先感谢您

class MyClass(GeneratedClass): 
def __init__(self): 
    GeneratedClass.__init__(self) 

def onLoad(self): 
    #put initialization code here 
    pass 

def onUnload(self): 
    pass 

def onInput_onStart(self): 
    motionProxy=ALProxy("ALMotion") 
    names = ['HeadYaw','HeadPitch'] 
times = [[0.5],[0.5]] 
motionProxy.angleInterpolation(names,[0.0,0.0],times,True) 

for i in range(3): 
motionProxy.angleInterpolation(names,[0.0,1.0],times,True) 
motionProxy.angleInterpolation(names,[0.0,-1.0],times,True) 

motionProxy.angleInterpolation(names,[0.0,0.0],times,True) 

self.onStopped() 

def onInput_onStop(self): 
    self.onUnload() #it is recommended to reuse the clean-up as the box is stopped 
    self.onStopped() #activate the output of the box 
+2

缩进你的'for'循环。切割和粘贴通常会拧入压痕。 – cdarke

回答

1

错误说,你的代码是不正确缩进。 对于Python需要缩进的每个代码块,像class身体,for循环体等:

class MyClass(GeneratedClass): 
    def __init__(self): 
     GeneratedClass.__init__(self) 

    def onLoad(self): 
     #put initialization code here 
     pass 

    def onUnload(self): 
     pass 

    def onInput_onStart(self): 
     motionProxy=ALProxy("ALMotion") 
     names = ['HeadYaw','HeadPitch'] 

     times = [[0.5],[0.5]] 
     motionProxy.angleInterpolation(names,[0.0,0.0],times,True) 

     for i in range(3): 
      motionProxy.angleInterpolation(names,[0.0,1.0],times,True) 
      motionProxy.angleInterpolation(names,[0.0,-1.0],times,True) 

     motionProxy.angleInterpolation(names,[0.0,0.0],times,True) 

     self.onStopped() 

    def onInput_onStop(self): 
     self.onUnload() #it is recommended to reuse the clean-up as the box is stopped 
     self.onStopped() #activate the output of the box 

检查从深入Python本章 - Indenting Code。上面的代码还不完整,它是更大的一部分,所以你无论如何不能仅仅使用这个代码来做一些事情。