Python 父类调用子类方法
class father():
def call_children(self):
child_method = getattr(self, 'out')# 获取子类的out()方法
child_method() # 执行子类的out()方法
class children(father):
def out(self):
print "hehe"
child = children()
child.call_children()
posted on 2017-11-20 17:25 DaSunWarman 阅读(5008) 评论(0) 收藏 举报
浙公网安备 33010602011771号