Python import用法

官方文档说明:

Python code in one module gains access to the code in another module by the process of importing it. 

Python import可以实现一个模块访问另一个模块。

导入包

import package

导入一个或者多个模块,并为模块起别名

import module1 as module1_alias, module2 as module2_alias, ...

导入包中的模块

from package import module

导入模块中的元素(类、变量、函数等等)

from module import module_element

参考链接:

https://docs.python.org/3/reference/import.html