Home  >  Article  >  Backend Development  >  A brief introduction to Python reloading

A brief introduction to Python reloading

巴扎黑
巴扎黑Original
2017-08-23 09:58:361435browse

In order to prevent the problem of two modules importing each other, Python defaults to importing all modules only once. If you need to re-import the module,

Python2.7 can use reload() directly, and Python3 can use the following One method:

Method 1: Basic method

from imp import reload

reload(module)

Method 2: Follow the routine, you can do this

import imp

imp.reload(module)

Method 3: Look at imp.py and find something, so you can still do this

import importlib

importlib.reload(module)

Method 4: According to the laws of heaven, of course it can also be done like this

from importlib import reload

reload(module)

The above is the detailed content of A brief introduction to Python reloading. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn