我有这些类。 人是父类和学生是子类: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