j
或者
J
作为后缀,具体格式为:
a + bj
a 表示实部,b 表示虚部。c1 = 12 + 0.2j print("c1Value: ", c1) print("c1Type", type(c1)) c2 = 6 - 1.2j print("c2Value: ", c2) #对复数进行简单计算 print("c1+c2: ", c1+c2) print("c1*c2: ", c1*c2)运行结果:
c1Value: (12+0.2j)
c1Type <class 'complex'>
c2Value: (6-1.2j)
c1+c2: (18-1j)
c1*c2: (72.24-13.2j)