☆─────────────────────────────────────☆
ludovic (荷叶粉蒸肉) 于 (Fri Mar 13 13:59:18 2009) 提到:
我的程序需要动态的加载一些库。
需求是这样的,程序会扫描一些目录,如果发现存在某个特定的 .py文件,就要加载这
个.py中的一个库,然后运行代码。然后,需要卸载这个库,再继续搜索下一个目录。
具体大概是这么个形式:
for dir in dirList:
if os.path.isfile(dir + "/lib.py"):
# Load the lib
#Run some code to generate output
# unload the lib(as all these libs have the same name)
请问这里的动态加载卸载怎么解决?
加载部分,import XXX中的XXX似乎不能含有路径(路径只能从PYTHONPAT