根据字符串动态调用对象的方法

class test(object):
    def show(self):
        print 'I am show'

    def talk(self):
        print 'I am talk'

method = 'show'
getattr(test(), method)()


posted on 2013-08-12 19:18  you Richer  阅读(136)  评论(0编辑  收藏  举报