复数运算
2016-09-19 本文已影响1人
bigtom
a = complex(2,4)
print a.real, a.imag #2.0 4.0
b = 3 - 4j
print b.real, b.imag #3.0 -4.0
print b.conjugate() #(3+4j)
print abs(b) #5
import cmath
print cmath.sqrt(-1) #1j
a = complex(2,4)
print a.real, a.imag #2.0 4.0
b = 3 - 4j
print b.real, b.imag #3.0 -4.0
print b.conjugate() #(3+4j)
print abs(b) #5
import cmath
print cmath.sqrt(-1) #1j