-
python多继承简单方法
- class people(object): #建创一个人类
- def __init__(self,name,age):
- self.name = name
- self.age = age
- def eat(self):
- print("%s is eatint'''''" % self.name)
- def talk(self):
- print("%s is talking......" % self.name)
- def sleep(self):
- print("%s is sleeping" % self.name)
- class Relation(object): # 创建一人交朋友类
- def make_friends(self,obj):
- print("%s is making friends %s" %(self.name,obj.name))
- class Man(people,Relation):#男人类 多继承,又继承交朋友类
- def __init__(self,name,age,money):
- #people.__init__(self,name,age)
- super(Man,self).__init__(name,age)
- self.money = money
- print("%s 一出生就有 %s money..." % (self.name,self.money))
- def piao(self):
- print("%s is piaoing....20s...done." % self.name)
- def sleep(self):
- people.sleep(self)
- print("man is sleeping")
- class Woman(people,Relation):#女人类 继承交朋友和人类 多继承
- def get_birth(self):
- print("%s is born a baby" % self.name)
- m1 = Man("zy",22,10)
- m1.eat()
- w1 = Woman("cxh",25)
- m1.make_friends(w1)
-
相关阅读:
移动端链接、点击事件、输入框去除背景高亮
Quartz.Net与MVC结合定时任务
Win10上使用SVN遇到的一些问题
Win7上的ASP.NET MVC3项目在Win10上运行的一个坑
《SQL必知必会》学习笔记(二)
《SQL必知必会》学习笔记(一)
数据库知识总结(表结构操作)
搭建三层架构(ASP.NET MVC+EF)
python线程中的全局变量与局部变量
ADO.NET Entity Framework学习笔录(一)
-
原文地址:https://www.cnblogs.com/fgxwan/p/9617203.html
Copyright © 2020-2023
润新知