1.使用临时变量
# 解法 1 - 使用临时变量
temp = b
b = a
a = temp
2.不使用临时变量
a = a + b
b = a - b
a = a - b
3.python独有方式
a = 3
b = 4
a, b = b, a
print("a == ",a ,"b == ",b)
# 解法 1 - 使用临时变量
temp = b
b = a
a = temp
a = a + b
b = a - b
a = a - b
a = 3
b = 4
a, b = b, a
print("a == ",a ,"b == ",b)