#单继承@微信公众号:Python机器视觉
class Person(object):
def __init__(self,name,age,height,weight):
self.name = name
self.age = age
self.height = height
self.weight = weight
def eat(self):
print("eating")
def walk(self):
print("walking")
def __str__(self):
return "name:%s,age:%d"%(self.name,self.age)
from person import Person
class Student(Person):
def __init__(self,name,age,height,weight):
#调用父类中的属性
super(Student,self).__init__(name,age,height,weight)
def studey(self):
print("studying")
from student import Student
stu = Student("tom",25,252,63)
print(stu.name)
#多继承
注意,当self.money = money编程私有属性时,即self.__money会出现报错现象
,说明私有属性不能直接继承
class Father(object):
def __init__(self,money):
self.money = money
def eat (self):
print("eati