两种动态载入修改后的python模块的方法

方案一:循环导入/删除模块

a.py

import sys, time

while True:
	from b import test
	test()
	del sys.modules(b)
	time.sleep(1)

b.py

def test():
	print "something"

方案二:reload模块

a.py

import time
import b

while True:
	b.test()
    reload(b)
	time.sleep(1)

b.py

def test():
	print "something"

posted on 2016-12-11 16:30  忧伤的南瓜  阅读(1478)  评论(0编辑  收藏  举报

导航