Python中的math 模块和cmath 模块

2025-04-12 02:49:28

Python中的数学运算常用的几种函数基本都在math 模块和cmath 模块里,下面简单介绍下math 模块和cmath 模块。

Python中的math 模块和cmath 模块

工具/原料

电脑

python

math 模块:

1、要使用 math模块的函数必须先导入:import math。

Python中的math 模块和cmath 模块

2、查看math模块的函数内容:dir(math)。

Python中的math 模块和cmath 模块

3、math 模块提供了许多对浮点数的数学运算函数。

Python中的math 模块和cmath 模块

cmath 模块:

1、要使用 cmath模块的函数必须先导入:import cmath。

Python中的math 模块和cmath 模块

2、查看cmath模块的函数内容:dir(cmath)。

Python中的math 模块和cmath 模块

3、cmath 模块运算的是复数,和math模块不一样。

Python中的math 模块和cmath 模块
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢