Chinaunix首页 | 论坛 | 博客
  • 博客访问: 164005
  • 博文数量: 22
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 248
  • 用 户 组: 普通用户
  • 注册时间: 2014-08-05 19:05
文章分类
文章存档

2018年(12)

2017年(10)

我的朋友

分类: Python/Ruby

2017-11-20 17:23:58

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()
阅读(5865) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~