#1.借助第三方变量
a = 10
b = 20
c = b
b = a
a = c
print(a)
print(b)
#2.使用运算符来实现,只能是数字
a = 30
b = 40
a = a + b
b = a - b
a = a - b
print(a)
print(b)
#3.使用异或运算符
a = 50
b = 60
a = a ^ b
b = a ^ b
a = a ^ b
print(a)
print(b)
#4.
a = 70
b = 80
a , b = b ,a
print(a)
print(b)
结果
20
10
40
30
60
50
80
70
Process finished with exit code 0