我正在尝试这个
In [1]: class Parent:
...: def __init__(self):
...: self.a =10
...: self.b =20
...:
In [3]: class NewParent(Parent):
def __init__self():
super(NewParent,self).__init__()
self.c =30
...:
当我这样做时
In [4]: c = NewParent()
In [5]: c
Out[5]: <__main__.NewParent instance at 0x2c98878>
In [6]: c.a
Out[6]: 10
In [7]: c.b
Out[7]: 20
In [8]: c.c
() ----> 1 cc 中的 AttributeError Traceback (最近一次调用最后一次)
AttributeError:NewParent 实例没有属性“c”