Home > Article > Backend Development > What are the keywords for importing modules in python
The keyword for importing modules in python is import. Import syntax: [import module name 1 [as alias 1], module name 2 [as alias 2], module name n [as alias n]]. If you need to use members in the module, you need to use the module name as a prefix.
#The keyword for importing modules in Python is import.
(Recommended learning: python tutorial)
Syntax:
import 模块名1 [as 别名1], 模块名2 [as 别名2], 模块名n [as 别名n]
Using the import statement in this syntax format will import the specified module All members in (including variables, functions, classes, etc.).
When you need to use members in a module, you need to use the module name (or alias) as a prefix, otherwise the Python interpreter will report an error.
# 导入sys整个模块 import sys # 使用sys模块名作为前缀来访问模块中的成员 print(sys.argv[0])
When using members in the sys module in a program, the module name must be added as a prefix.
The above is the detailed content of What are the keywords for importing modules in python. For more information, please follow other related articles on the PHP Chinese website!