继承

class Employee:
    def __init__(self,salary):
        self.salary=salary
    def work(self):
        print('正在写代码,工资是:',self.salary)

class Customer:
    def __init__(self,favorite,address):
        self.favorite=favorite
        self.address=address
    def info(self):
        print('我的爱好是%s,地址是:%s'%(self.favorite,self.address))

class Manager(Customer,Employee):#注意Customer和Employee的顺序,此例中如果反过来会报错
    pass



m=Manager('IT','北京')
m.info()

你可能感兴趣的:(继承)