Python(七)

Python(七)

1、Python的自省机制
Python的自省机制是通过一定的机制查询到对象内部的结构。
2、super调用父类的__init__函数

class A():
    def __init__(self):
        print('A')

class B(A):
    def __init__(self):
        print('B')
        super().__init__()

if __name__=='__main__':
    b = B()
	#B
	#A

猜你喜欢

转载自blog.csdn.net/zxq6661/article/details/112974758
今日推荐