我正在参加机器人课程,并在Calico中导入了Myro库。 timeRemaining应该是Myro库中的预定义函数,但它一直说它是未定义的。“timeremaining is not defined”错误
有用于Myro功能的在线手册,甚至这不起作用:
while timeRemaining(5):
print "running..."
这是确切的错误
NameError: name 'timeRemaining' is not defined
我甚至直接从书上抄袭代码和它的说法timeRemaining
未定义。该书的代码应该可以工作。
其他预定义功能,如turnLeft
,forward(speed, time)
等工作,但timeRemaining
没有。
下面是从白布书Learning Computing With Robots
def main():
# Run the robot for 60 seconds
while timeRemaining(60):
L, C, R = getLight()
# motors run proportional to light
motors(normalize(L), normalize(R))
stop()
代码权当我尝试运行main()
这是行不通的。它说timeRemaining是未定义的。我无法弄清楚什么是错的。
你有进口myro吗?最简单的就是'from myro import *' – 2014-10-12 02:19:03
是timer()定义的吗?在定时器(5)秒钟:打印“奔跑”,秒,“...” – fluidmotion 2014-10-12 02:29:14
是的,我进口了Myro。这就是我从Myro导入*'表示它是未定义的。 – user3577397 2014-10-12 02:34:54