学习笔记(07):21天通关Python(仅视频课)-实例方法与自动绑定self及使用类调用实例方法...

立即学习: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)
发布了25 篇原创文章 · 获赞 4 · 访问量 609

猜你喜欢

转载自blog.csdn.net/happyk213/article/details/105138751
今日推荐