标准库与拓展库对象的导入与使用

标准库与拓展库对象的导入与使用
1.import 模块名【as别名】

 import math #导入math库 
 math.sin(0.5) #求0.5(弧度)的正弦

2.from 模块名 import 对象名【as别名】

from math import sin      #只导入模块中的指定对象,访问速度较快
 sin(0.5)

3.from 模块名 import *

 from math import *            #导入标准库math中的所有对象
 sin(3)                                #求正弦值
 gcd(36,18)                       #最大公约数
 pi                                      #常数pi

你可能感兴趣的:(python课本)