Study Notes (07): 21 days clearance Python (Video Lesson only) - Examples of methods and automatically bound self and use the class instance method is invoked ...

Learning immediately: https://edu.csdn.net/course/play/24797/282187?utm_source=blogtoedu

class TestA:
    def __init__(self,height=11):
        self.height =height

    def testa(self):
        self.height +=10
        return self
    def testb(self):
        self.testa()
        testbname = 'testbb'
        return testbname
ta = TestA()
print(ta.height)
ta2 = TestA('testaa')
print(ta2.height)
ta3 =TestA()
ta3.testa().testa().testa()
TestA.testa(ta3)
print(ta3.testb())
print(ta3.height)
Published 25 original articles · won praise 4 · Views 609

Guess you like

Origin blog.csdn.net/happyk213/article/details/105138751