|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- class A(object):
- def __init__(self):
- print "enter A"
- print "leave A"
- class B(object):
- def __init__(self):
- print "enter B"
- print "leave B"
- class C(A):
- def __init__(self):
- print "enter C"
- super(C, self).__init__()
- print "leave C"
- class D(A):
- def __init__(self):
- print "enter D"
- super(D, self).__init__()
- print "leave D"
- class E(B, C):
- def __init__(self):
- print "enter E"
- B.__init__(self)
- C.__init__(self)
- print "leave E"
- class F(E, D):
- def __init__(self):
- print "enter F"
- E.__init__(self)
- D.__init__(self)
- print "leave F"
复制代码
EE = E()
enter E
enter B
leave B
Traceback (most recent call last):
File "<pyshell#21>", line 1, in <module>
EE = E()
File "/Users/zhujunjie/Desktop/a.py", line 27, in __init__
C.__init__(self)
TypeError: __init__() takes 1 positional argument but 2 were given
为什么会报错呀?
缩进问题,你的缩进不统一,类里面是2个空格,函数里面缩进只有1个空格
|
|