[python]代码库
class people(object):
name:''
age=0
__weight=0
def __init__(self,n,a,w):
self.__name=n
self.age=a
self.__weight=w
def speak(self):
print("%s 说: 我%s岁。"%(self.name,self.age))
class student(people):
name=''
grade=''
age = 0
def __init__(self,n,a,w,g):
self.name=n
self.age=a
self.__weight=w
self.grade=g
def speak(self):
print("%s said:i am %d years old%(self.name,self.age)")
class speaker():
topic=''
name=''
def __init__(self,n,t):
self.name=n
self.topic=t
def speak(self):
print("我是%s,一个演说家,今天演讲的主题是%s"%(self.name,self.topic))
class sample(student,speaker):
a=''
def __init__(self,n,a,w,g,t):
student.__init__(self,n,a,w,g)
speaker.__init__(self,n,t)
class bird(object):
def __init__(self):
self.hungry=True
def eat(self):
if self.hungry:
print("Aaaah")
self.hungry=False
else:
print("No thaks")
class songbird(bird):
def __init__(self):
super(songbird,self).__init__()
bird.__init__(self)
self.sound="swaplqw"
def sing(self):
print(self.sound)
sb=songbird()
sb.eat()
sb.eat()
class classa(object):
@classmethod
def func_a(cls):
print(type(cls),cls)
classa.func_a()
ca=classa()
ca.func_a()