Python cmath.polar() 方法

定义和用法

cmath.polar() 方法将复数转换为极坐标。它返回包含模数和相位的元组。

在极坐标中,复数由模数 r 和相位角 phi 定义。

实例

将一个复数转换为极坐标形式:

# 导入cmath以进行复数运算  
import cmath  
  
# 查找复数的极坐标  
print (cmath.polar(2 + 3j))  
print (cmath.polar(1 + 5j))

亲自试一试

语法

cmath.polar(x)

参数

参数 描述
x 必需。要计算其极坐标的数字。

技术细节

返回值: 元组值,表示极坐标。
Python 版本: 2.6