我遇到了同样的问题,您启发了我去解决这个问题。
from types import ModuleTypetry: from importlib import reload # Python 3.4+except importError: # Needed for Python 3.0-3.3; harmless in Python 2.7 where imp.reload is just an # alias for the builtin reload. from imp import reloaddef rreload(module): """Recursively reload modules.""" reload(module) for attribute_name in dir(module): attribute = getattr(module, attribute_name) if type(attribute) is ModuleType: rreload(attribute)
或者,如果您使用的是IPython,则只需使用
dreload或传递
--deep-reload启动即可。



