python类的继承

class People:
    def __init__(self,name):
        self.name=name
    def talk(self):
        print ("i'm {}".format(self.name))

class Student(People):
    def talk(self):
        People.talk(self)
        print ("i'm a Student")
    def study(self):
        print ("i can study")

class mgr(People):
    def mgr(self):
        print("i'm a mgr")
#不能同时继承Student和父类People
class Studentmgr(Student,mgr):
    def manage(self):
        print("i can manage")

p=People('mark')
p.talk()
s=Student('ben')
s.talk()
s.study()
sm=Studentmgr('jane')
sm.talk()
sm.study()
sm.mgr()
sm.manage()

  

原文地址:https://www.cnblogs.com/luozx207/p/9360308.html