我是python新手。我得到了Syntax Error: invalid syntax & object module is not callable
谢谢你的帮助
在Spot.py在
class Spot(object):
isBunny = bool()
UP = 0
SLEEP = 2
def __init__(self, newIsBunny):
self.isBunny = newIsBunny
self.nextCycle = self.UP
在测试.py在
^{pr2}$
Tags:
除了Borgleader说的,而不是
使用
^{pr2}$这将修复“模块不可调用”错误。在
当你说
那么“Spot”就是整个模块。点。点是Spot模块中的Spot类,这正是您真正想要的。使用
from Spot import Spot
语法可以让您只从Spot模块中提取Spot类,并将其称为Spot。在首先,类中的代码应该缩进。这就是python知道代码是类的一部分的方式(与缩进告诉python哪个代码是函数或循环的一部分一样)。在
其次,你在
if i==Spot.SLEEP
后面错了一个:
相关问题 更多 >
编程相关推荐