python動的呼び出し方法
582 ワード
#!/usr/env python
#conding:utf-8
def test():
classname = "classname"
method = "echo"
module = __import__(classname)
c = getattr(module,classname)
obj = c()
mtd = getattr(obj,method)
mtd()
if __name__ == '__main__':
test()
#!/usr/env python
#coding:utf-8
class classname:
def mod1(self):
print "call mod1"
def echo(self):
print "call eacho"