python动态加载模块
#!/usr/bin/python#coding:utf-8#导入动态加载模块的方法importimpfunc_name 模块名字path 模块的路径#使用方法module = imp.load_source(func_name,path)下面就可以使用函数了module.func_name()也可以是分发函数func= getattr(module,func_n
·
#!/usr/bin/python
#coding:utf-8
#导入动态加载模块的方法
import imp
func_name 模块名字
path 模块的路径
#使用方法
module = imp.load_source(func_name,path)
下面就可以使用函数了
module.func_name()
也可以是分发函数
func= getattr(module,func_name)
func()就可以使用函数了
更多推荐
所有评论(0)