1
即時得到這個例外在Python,AttributeError異常:「對象類型‘實例’有沒有屬性
Exception AttributeError: "type object 'instance' has no attribute 'jumlah_ada'" in <bound method kucing.__del__ of <__main__.kucing instance at 0x7fe39d827e18>> ignored
當我運行語法:
class kucing:
jumlah_ada = 0
def __init__(self, tipe):
self.tipe = tipe
kucing.jumlah_ada +=1
def __del__(self):
kucing.jumlah_ada -=1
def data_kucing(self):
print "Tipe : ",self.tipe
print "Jumlah kucing : ",kucing.jumlah_ada
kucing1 = kucing("Anggora")
kucing2 = kucing("Persia")
kucing3 = kucing("Himalayan")
print "jumlah kucing : ",kucing.jumlah_ada
kucing1.data_kucing()
del kucing2
print "jumlah kucing : ",kucing.jumlah_ada
我試圖修復它,但我還是不行。
是關於這個問題有什麼想法?
您能否修理您的縮進? –