import unittest
class Person(object):
def age(self):
print ("this is father's age")
def sex(self):
print ("this is father's sex")
class student(Person):
def student(self):
print ("student's ")
def age(self):
super(student,self).age() #继承父类
print ("this student's age") #覆盖父类
if __name__ == '__main__':
s=student()
s.age()
operation result:
this is father's age
this student's age
[Finished in 0.1s]
1, super inherited introduction
super (B, self) .__ init __ () is understood: super (B, self) first find the parent of B (that is, class A), then the subject self converting class B is the object of class A, then "are conversion "of the object class a call your own __init__ function.
2, TypeError python in super occur: must be type, not classobj causes and solutions
python in the super class can only be applied to new, not used in the classic category
called new class is that all classes must have inherited class, if nothing do not want to inherit, inherits the object class