How do I reload a module after changing it?(更改后如何重新加载模块?)
问题描述
带有 Python 3.4.2 的 Python 控制台
我在 PyCharm 社区版 4.5.4 的 Python 控制台中定义了一个模块中正确运行的函数:
重载测试.py:
Python Console with Python 3.4.2
I defined a function in a module which runs correctly in Python Console in PyCharm Community Edition 4.5.4:
ReloadTest.py:
Python Console:
After I modified the function to "Version B", PyCharm can't find the change, and importlib.reload(ReloadTest)
gives me error.
I must reload the Python Console or restart PyCharm every time I modify a module. What did I do wrong? What is the best way to handle this?
ReloadTest.py:
Python Console:
Get it to work!
Instead of from Module import function
, I should import the whole module import Module
, then call the function by Module.function()
. This is because
and
can't go together.
After making changes:
这篇关于更改后如何重新加载模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!