我有這些類。 人是父類和學生是子類:python 2.7 __init __()只需要2個參數(3給出)
#Person class
class person(object):
def __init__(self, name):
self.name = name
def pr(self):
print "I'm " + self.name
#Student class
from personClass import person
class student(person):
def __init__(self, avr, name):
self.avr = avr
super(student, self).__init__(self, name)
def pr(self):
super(student, self).pr(self)
print "My avrage is " + str(self.avr) + "\n"
我得到第17行這個錯誤,當我試圖讓我的類的實例初始化()到底需要2個參數(3給出)和 人。 init(self,name)正常工作。 我的代碼有什麼問題,如何在python 2.7中使用super?
你是如何創建一個對象? – thefourtheye 2014-10-18 07:41:30