Learning immediately: https://edu.csdn.net/course/play/24797/282192?utm_source=blogtoedu
class TestFu: DEF fuleifun (Self): Print ( 'which is the parent class TestFu of [fuleifun] Function') DEF fuleifun2 (Self): Print ( 'which is the parent class TestFu of [fuleifun2] Function') class TestFu2: DEF fuleifun (Self): self.x = Print ( 'which is the parent class of TestFu2] [fuleifun function') DEF fuleifunOther (Self): Print ( '[which is] funleifunOther TestFu2 the parent class') # inherit parent class function class TestZi (TestFu): Pass zi and TestZi = () zi.fuleifun () Print ( '*' * 50) '' ' multiple inheritance multiple inheritance, if multiple parent class have the same function, using inheritance priority class front function the same function [fuleifun], [TestFu2] preferably used in the [] function fuleifun '' ' class TestZi2 (TestFu2, TestFu): pass zi2 = TestZi2() # TestFu2] [class function call in zi2.fuleifun () # class calls the function [] TestFu zi2.fuleifun2 () zi2.fuleifunOther () Print ( '*' * 50) '' ' rewritable parent TestFu2] [in] [fuleifunOther function ' ' class TestZi3 (TestFu2): DEF fuleifunOther (Self): Print (' which is a subclass of the parent [rewrite] [TestZi3 TestFu2] in [] function fuleifunOther ') zi3 = TestZi3 () zi3.fuleifunOther ()
1. Use multiple inheritance to inherit priority function in the parent class