import math.sin as sin
这个写法为什么不对呢?
import math.sin就是导入了math的sin
所以可以直接使用sin函数了
因为sin并非模块(module),只是函数,import math.sin已经错了,可写成
from math import sin
from math import sin 这样
from math import sin就可以了,
出错原因是math不是一个独立的包,该模块提供了对 C 标准定义的数学函数的访问
>>> import math.sin
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'math.sin'; 'math' is not a package