1 - 导入python 模块

1. 导入python 模块的基本方式

2. 为导入的python 模块指定别名

import math
from math import cos, tan
from math import *

print(math.sin(1.23))
print(cos(2.34))
print(tanh(1.23))

# 指定别名 as
# 一旦指定了别名,原来的名字就不能用了
import math as mt
print(mt.sin(2))

from math import cos as cs
print(cs(3))
0.9424888019316975
-0.695563326462902
0.8425793256589296
0.9092974268256817
-0.9899924966004454

2 - 设置python 模块搜索路径

发布了107 篇原创文章 · 获赞 101 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_29339467/article/details/104163576