我有一个foo.py
文件
def foo():
print "test"
在IPython中我使用:
In [6]: import foo
In [7]: foo.foo()
test
然后我将 foo()
改为:
def foo():
print "test changed"
在IPython中,调用后的结果仍为test
:
In [10]: import foo
In [11]: foo.foo()
test
然后我使用:
In [15]: del foo
In [16]: import foo
In [17]: foo.foo()
test
我在与 foo.py
同文件夹下删除了 foo.pyc
,但运行时仍未更新。
请问如何在运行时重新导入更新后的代码?