An import module
from the module is introduced, generally used
import sys(用sys模块举例) #这种方式导入模块,要使用这个模块其中的功能,语法为模块名称**.**功能,如print(sys.path)
from sys import path #这种方式导入模块要使用模块中的功能,直接功能名即可print(sys),如果要导入该模块多个功能可以以逗号隔开
from SomeMode import * #这种方式和第二种一样只是把具体的功能名换成了*(导入所有),这种方式也有弊端,假如你导入的模块都有一个名为open的功能,那么后面导入的就会把前面的覆盖,此情况下,建议使用第一种
Second, the import module's what happens when
import to import a module when the module is first to determine whether imported by sys.modeles, no longer do what True, False if it is then open up a new space for independent module, in this space to execute code.
Third, the order of introduction of the module
python中导入模块的顺序(模块写在最上面):
引入内置模块
引入扩展模块
引入自定义模块
Fourth, alias
import modele1 import write as write1 #假设2个模块都有write方法可以用别名区分
import modele2 import write as write2
Some supplements
above when it comes to importing modules will open up a new space, this will only import import to open up a space used, and from it will not.
使用import导入,path可以正常执行
使用from导入,可以看到path已经被覆盖