函数反射


#!/usr/bin/env python
#_*_ coding:utf-8 _*_

temp = 'mysqlhelper'
func = 'count'
modle = __import__(temp)
Function = getattr(modle,func) #如果模块中找到字符串,返回函数
print Function()


以字符串的形式导入模块,并以字符串的形式执行函数.
原文地址:https://www.cnblogs.com/fengjian2016/p/5248590.html