Each module is loaded into memory only once during an interpreter session or during a program run, regardless of the number of times it is imported into a program. If multiple imports occur, the module’s code will not be executed again and again.
Suppose during an interactive session, you have imported a module, and the code of the module is changed while you are using these modules. You might want to use the updated module code by importing it again, but this is not possible since any imports that are done after the first import just use the already loaded module object, the module is not reloaded and its code is not executed again. You have to restart the interpreter session or execute the program again to reload the module. However, you can force a reload by using the reload function from the importlib module. This way we can get the updated version of the already loaded module without exiting the interpreter session.
>>> import module1
>>> from importlib import reload
>>> reload(module1)
标签:again,code,Python,module,Reloading,reload,session,loaded From: https://www.cnblogs.com/zhangzhihui/p/18332029