Python从模块导入函数

来源:互联网 发布:希望有鬼知乎 编辑:程序博客网 时间:2024/06/06 02:30

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



0 0