- 什么是Python的模块(Module)
Python的一个模块实际上就是一个Python文件(*.py)
- 使用
import
关键字引入外部模块
import math #引入math模块
math.cos(90) #cos是math模块里定义的余弦函数
如果只想导入某模块的一部分,可以使用from...import
from mathutils import Matrix, Vector #从mathutils模块中引入Matrix和Vector
v = Vector((0, 0, 0))
-
一个模块只会被
import
一次 -
搜索范围
- 当前目录
PYTHONPATH
环境变量下- 其它默认目录