Python 3 对象:4
Live Demo
#!/usr/bin/python3
class Parent: # 父类
def myMethod(self):
print ('Calling parent method')
class Child(Parent): # 子类
def myMethod(self):
print ('Calling child method')
c = Child() # 创建子类对象实例
c.myMethod() # 调用重写后的方法
INFO