__bases__在python3中的使用
看到了第39课里面,__bases__函数在调用过程中会出现Traceback (most recent call last):
File "C:\Users\22487\Desktop\test.py", line 10, in <module>
A.__bases__ += (B,)
TypeError: Cannot create a consistent method resolution
order (MRO) for bases object, B
的报错,请问是什么情况啊 ?
class D:
pass
class A(D):
def get_a(self):
print('a')
class B:
def get_b(self):
print('b')
class E:
pass
class C(E):
pass
print(C.__bases__)
C.__bases__ += (A, B, ) 希望对你有用,这应该是python2的用法,python3的新用法
页:
[1]