我的工作與樹冠Python項目,用我自己的圖書館,這是我從一次修改時間更改或添加里面的功能。需要重新加載庫在Python中,有雨棚
在myfile.py
開頭,我有from my_library import *
,但是如果我在這個庫中改變一個函數並且再次計算myfile.py
,它會繼續使用我的函數以前的版本。
我試過reload
功能:
import my_library
reload(my_library)
from other_python_file import *
from my_library import *
,它使用我最近改變了圖書館。
但如果是:
import my_library
reload(my_library)
from my_library import *
from other_python_file import *
它給我的結果,由於版本加載我第一次推出myfile.py
。
爲什麼會出現不同的結果反轉第3和第4行?
可能重複的[如何卸載(重新加載)Python模塊?](http://stackoverflow.com/questions/437589/how-do-i-unload-reload-a-python-module) – Styrke
可能複製[刷新Python模塊(http://stackoverflow.com/questions/27899348/reload-python-module) –
@Simakis帕納約蒂斯的:在你提到的問題,問題是,有沒有「進口my_module」但我把它。這不是同一個問題。 – trapuck