2024年6月2日发(作者:)

print("d的数据类型是:", type(e), "="*5, "e的值为:", e)

print("f的数据类型是:", type(f), "="*5, "f的值为:", f)

print("e的数据类型是:", type(g), "="*5, "g的值为:", g)

# d的数据类型是: ===== e的值为: 1.0

# f的数据类型是: ===== f的值为: 2.0

# e的数据类型是: ===== g的值为: 0.0

转换为复数类型

a = 1

b = 3.14

c = "2"

h = complex(a, b)

i = complex(b, a)

j = complex(c)

print("h的数据类型是:", type(h), "="*5, h)

print("i的数据类型是:", type(i), "="*5, i)

print("j的数据类型是:", type(j), "="*5, j)

# h的数据类型是: ===== (1+3.14j)

# i的数据类型是: ===== (3.14+1j)

# j的数据类型是: ===== (2+0j)