Janie.Wei 2015-09-11 09:21 采纳率: 0%
浏览 1755

python中关于super调用父类构造方法

class Person:
def init(self,n,s):
self.name=n
self.sex=s
print "Person"

class Student(Person):
def init(self,n,s,j):
self.job=j
print "test"
super(Person,self).__init__(n,s)
print "Student"

s=Student("janie","woman","student")

 super那条语句,哪里有问题,为什么报错

 F:\python\python.exe F:/python程序/test.py

Traceback (most recent call last):
File "F:/python程序/test.py", line 17, in
s=Student("janie","woman","student")
File "F:/python程序/test.py", line 13, in init
super(Person,self).__init__(n,s)
TypeError: must be type, not classobj
test

Process finished with exit code 1

  • 写回答

3条回答 默认 最新

  • devmiao 2015-09-12 00:00
    关注
    评论

报告相同问题?