调用模块函数时、模块的函数名如何用变量来代替?
定义一个模块aaa.py、内容如下该模块有2个函数、:
def test1(): print 'test1' def test2(): print 'test2'
然后在另一文件中导入模块、代码如下:
import aaa mytest='test1' aaa.mytest()
如上代码报错:提示AttributeError: 'module' object has no attribute 'mytest'
这样无法达到我想要的结果、请问有什么办法实现吗??