1、定义
可将模块视为扩展,通过将其导入可以扩展
Python
功能。要导入模块,可使用特殊命令
import
。
2、举例
>>> import math
>>> math.floor(32.9)
32
3、拓展
通过使用命令
import
的变种
from module import function
,可在调用函数时不指定模块前缀。
>>> from math import sqrt
>>> sqrt(9)
3.0