花式赋值
一、链式赋值
Copya = 10
b = 10
c = 10
d = 10
print(f'a:{a}, b:{b}, c:{c}, d:{d}')
Copya:10, b:10, c:10, d:10
Copya = b = c = d = 10
print(f'a:{a}, b:{b}, c:{c}, d:{d}')
Copya:10, b:10, c:10, d:10
二、交叉赋值
Copyx = 100
y = 200
temp = x
x = y
y = temp
print(f'x:{x}')
print(f'y:{y}')
Copyx:200
y:100
Copyx, y = y, x
print(f'x:{x}')
print(f'y:{y}')
Copyx:100
y:200