2018-01-05 重写父类的构造方法

```

class A(object):

    def __init__(self,name):

        self.name = name

    def func(self):

        return 'from AA'

class B(A):

    def __init__(self,name,age,sex):

        super().__init__(name)

        self.age = age

        self.sex = sex

a = A('Parker')

b = B('Alice',23,'female')

print(a.name,b.age,b.func())

```

你可能感兴趣的:(2018-01-05 重写父类的构造方法)