0
在Python,限定了接受一個參數在其__init__
方法的類時:當初始化類,AttributeError的:「INT」對象沒有屬性「[則parametername]」
class animal:
number_of_legs = 0
def __init__(nlegs, self):
self.number_of_legs = nlegs
a = animal(3)
我得到以下錯誤:
AttributeError: 'int' object has no attribute 'number_of_legs'