import Precautions

Parent class inside __name__ like this property still in the subclass inherits
the variable name in front of such a variable name only underlined this variable can not be imported at the time of other import file
xx
: In order to avoid conflicts can define a variable behind underscore, such as class _ this can be used normally
why you want to privatize the whole of it?
Because a file in a variable in this file in normal use, but there are other files will be a conflict. So make a privatization

import as

import a as AA

The above process is to first define and then introduced into a variable named an A, and thereafter the module to the introduced point A
when introduced into the module must appear unsuccessful authentication sys.path

import time unsuccessful

import sys
sys.path

value path 'is a list of print are listed below
Here Insert Picture Descriptionso when the program first began to import the call import.path
search the name you want to import the path of the path
and you can specify that the first search

sys.path.append
sys.path.insert

If the insert (0) then it means is inserted into the first

Re-import module

import has a feature to prevent the re-import program
when aa program running in another window to modify the program so aa aa in the original program will not be changed in time to re-import import nor the following code to re-import code

from imp import reload
reload(aa)

Import Scenario
whole a server, the server can not be stopped. But it takes place in this process I need to modify some code, then you can
modify reload. But only import can not be used with other

Multi-module development knowledge

Here Insert Picture Description
However, import common have to write common.xxxx

from common import HANDLE_FLAG
# 让这个变量指向了common里的变量
# 代码中直接写HANDLE_FLAG
HANDLE_FLAG =Ture 

Here Insert Picture DescriptionBefore HANDLE_FLAG point to point to the True Flase now HANDLE_FLAGA
but can not make changes to local variables common file changes
if you want to modify, then have to change from a local variable to be global variables

Published 41 original articles · won praise 0 · Views 387

Guess you like

Origin blog.csdn.net/weixin_41621686/article/details/104108996