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

查看全部
weijie_home
taozi_home
2015/09/11 09:21
  • python
  • 点赞
  • 收藏
  • 回答
    私信

3个回复