Dry Goods: Introduction to Python's Inheritance of Object Classes

 

 

Foreword

The text and pictures of the text come from the Internet and are only for learning and communication. They do not have any commercial use. The copyright belongs to the original author. If you have any questions, please contact us in time for processing.

Author: python vision algorithms

PS: If you need Python learning materials, you can click the link below to obtain http://t.cn/A6Zvjdun

Single inheritance

 

The output is:

python 说: 我已经 20 岁了,我现在在读 7 年级

Multiple inheritance

It should be noted that the order of parent classes in parentheses, if the parent has the same method name, and it is not specified when the subclass is used, Python searches from left to right, that is, when the method is not found in the subclass, it searches from left to right Whether the parent class contains methods.

 

 

The output of executing the above program is:

我叫 Tim,我是一个演说家,我演讲的主题是 Python

Guess you like

Origin www.cnblogs.com/python0921/p/12680811.html