练习练习~
Topic source按照你的例子编写的程序,为啥,是这样显示的呢?(代码都一样,所以有些地方就不复制了)
class Sample(Total, Student, People): def init(self, name, age, grade, like, say): Total.init(self, name, say) Student.init(self, name, age, grade, like)
a = Sample("Jack", 12, 5, "Python", "JAVA+Python") a.print_date()
为啥执行的结果是这样的呢?? My name is Jack,12 years old in 5 grade,I like Python
我已经把People的父类继承给了Student 最后的Sample,因为Student已经继承了People 所以class Sample就不用加People, 直接
class Sample(Total,Student):
然后,你把Tolat 和 Student的位置互换一下
Class Sample(Student,Total):
再执行一下结果 如果要把People加上Sample的话,Student就不要继承People了~~
- 方法名同,默认调用的是在括号中排前地父类的方法
- 1
呆呆的设计师