您的位置:首页 > 编程语言 > Python开发

Python从模块导入函数

2016-10-23 14:38 267 查看

Python从模块导入函数

第一种

>>> import math
>>> math.sqrt(4)
2.0


>>> import math as mymath
>>> mymath.sqrt(4)
2.0

第二种

>>> from math import sqrt
>>> sqrt(4)
2.0


>>> from math import sqrt as mysqrt
>>> mysqrt(4)
2.0


>>> from math import sqrt,sin,tan


>>> from math import *

第三种

>>> mymath= __import__('math')
>>> mymath.sqrt(4)
2.0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python 函数 导入模块