标签:col reduce setattr attribute for get _for 方法 __str__
1 class A: 2 def test(self): 3 print("A --- test方法") 4 5 def demo(self): 6 print("A --- demo方法") 7 8 class B: 9 def test(self): 10 print("B --- test方法") 11 12 def demo(self): 13 print("B --- demo方法") 14 15 16 class C(A,B): 17 pass 18 19 20 c = C() 21 print(dir(c)) #dir()显示该类中所有的方法和属性 22 c.test() 23 c.demo() 24 print(C.__mro__) #向上查询顺序
[‘__class__‘, ‘__delattr__‘, ‘__dict__‘, ‘__dir__‘, ‘__doc__‘, ‘__eq__‘, ‘__format__‘, ‘__ge__‘, ‘__getattribute__‘, ‘__gt__‘, ‘__hash__‘, ‘__init__‘, ‘__le__‘, ‘__lt__‘, ‘__module__‘, ‘__ne__‘, ‘__new__‘, ‘__reduce__‘, ‘__reduce_ex__‘, ‘__repr__‘, ‘__setattr__‘, ‘__sizeof__‘, ‘__str__‘, ‘__subclasshook__‘, ‘__weakref__‘, ‘demo‘, ‘test‘] A --- test方法 A --- demo方法 (<class ‘__main__.C‘>, <class ‘__main__.A‘>, <class ‘__main__.B‘>, <class ‘object‘>)
标签:col reduce setattr attribute for get _for 方法 __str__
原文地址:https://www.cnblogs.com/yifengs/p/11345754.html