Python模組reload
Python提供了reload()方法,它可以重新匯入已import的模組。
這個功能在Python互動式模式下非常有用,如果外部編輯器修改了原始檔,你可以不退出互動式環境,直接重新匯入被修改的模組即可。
語法:
# Python2.x
reload(module)
# Python 2.x->Python3.3
import imp
imp.reload(module)
# Python3.4+
import importlib
importlib.reload(module)
示例:
>>> import test
>>> test.test_print() # 原模組輸出值
0
>>> import importlib
>>> importlib.reload(test)
<module 'test' from '/Volumes/pytest/test.py'>
>>> test.test_print() # 修改模組後輸出的值
1
相關文章
- python 模組:itsdangerous 模組Python
- Python模組:time模組Python
- Python模組之urllib模組Python
- python模組之collections模組Python
- Python 模組Python
- [Python模組學習] glob模組Python
- reload在python中的使用Python
- Python中模組是什麼?Python有哪些模組?Python
- Python Execl模組Python
- Python mongoHelper模組PythonGo
- Python——JSON 模組PythonJSON
- [Python] pipe模組Python
- Python - 模組包Python
- python——typing模組Python
- Python functools 模組Python
- Python pymsql模組PythonSQL
- Python:requests模組Python
- python之模組Python
- 15 Python模組Python
- python–inspect模組Python
- python random模組Pythonrandom
- python Subprocess 模組Python
- Python:pathlib模組Python
- python APScheduler模組Python
- Python webargs 模組PythonWeb
- Python模組(module)Python
- Python-模組Python
- python collections模組Python
- python 模組fnmatchPython
- python–模組之random隨機數模組Pythonrandom隨機
- python–模組之os操作檔案模組Python
- Python基礎12(模組與datetime模組)Python
- Python常用模組(random隨機模組&json序列化模組)Pythonrandom隨機JSON
- Python 內建模組:os模組Python
- python模組之configparserPython
- python的logging模組Python
- python模組之hashlibPython
- python模組詳解Python