python 用字符串导入函数


1
inp=input('moudulus: ') 2 d= __import__(inp) 3 inp_func=input('func name: ') 4 tfun=getattr(inp,inp_func) 5 tfun()

 hasattr(modulus,funcname)模块中有没有这个函数

setattr(modulus,funname,lambda )创建全局变量或者函数

delattr(modulus,funcname)删除

posted @ 2017-03-24 08:52  ezway  阅读(749)  评论(0编辑  收藏  举报