【发布时间】:2013-10-03 02:46:30
【问题描述】:
在 Python 中,当定义一个在其__init__ 方法中接受参数的类时:
class animal:
number_of_legs = 0
def __init__(nlegs, self):
self.number_of_legs = nlegs
a = animal(3)
我收到以下错误:
AttributeError: 'int' 对象没有属性 'number_of_legs'
【问题讨论】: