python2、python3:
python子类调用父类初始化函数有两种方式,以下代码在python2和python3都能运行:
class A(object): def __init__(self, x): self.x = x # 方法一 class B(A): def __init__(self, x, y): A.__init__(self, x) self.y = y
python子类调用父类初始化函数有两种方式,以下代码在python2和python3都能运行:
class A(object): def __init__(self, x): self.x = x # 方法一 class B(A): def __init__(self, x, y): A.__init__(self, x) self.y = y