如何重新加载此模块?

时间:2012-11-13 19:29:16

标签: python module reload

from mypackage.pkg import mymodule
...
reload(mypackage.pkg.mymodule)

结果为NameError: global name 'mypackage' is not defined.

如何重新加载mymodule?

1 个答案:

答案 0 :(得分:8)

from mypackage.pkg import mymodule

reload(mymodule)

import mypackage.pkg.mymodule
...
reload(mypackage.pkg.mymodule)