python - 执行父类中的方法

执行父类中的方法:

class C1:
    def f1(self):
        print('c1.f1')
        return 123
class C2(C1):
    def f1(self):
        #主动执行父类的f1方法
        ret = super(C2,self).f1()
        print('c2.f1')
        return ret
obj = C2()
obj.f1()

out:

c1.f1
c2.f1

posted @ 2016-06-26 17:33  unixfbi.com  阅读(567)  评论(0编辑  收藏  举报