separate real and imaginary part of a complex numb

2019-04-03 23:53发布

I have need to extract the real and imaginary elements of a complex number in python. I know how to make a list into a complex number... but not the other way around.

I have this:

Y = (-5.79829066331+4.55640490659j)

I need:

Z = (-5.79829066331, 4.55640490659)

and I will also need each part if there is a way to go directly without going by way of Z:

A = -5.79829066331
B = 4.55640490659

https://docs.python.org/2/library/functions.html#complex

Thanks!

2条回答
Rolldiameter
2楼-- · 2019-04-04 00:05
Z = (Y.real, Y.imag)
A = Y.real
B = Y.imag
查看更多
仙女界的扛把子
3楼-- · 2019-04-04 00:15
Y = (-5.79829066331+4.55640490659j)

Z = (Y.real, Y.imag)

A = Y.real
B = Y.imag
查看更多
登录 后发表回答