Home > Article > Backend Development > Python reload module method
To prevent the problem of two modules importing each other, Python only imports all modules once by default. If you need to re-import the module,
Python2.7 can use reload() directly, and Python3 can use the following methods:
Method one: basic method
from imp import reload
reload(module)
Method two: follow the routine, you can do this
import imp
imp.reload(module)
method Three: Take a look at imp.py and find something, so you can also do this
import importlib
importlib.reload(module)
Method 4: According to the laws of nature, of course you can also do this
from importlib import reload
reload(module)