a = 1

b = 2

a, b = b, a
print(a,b)

Python 用一行代码实现数值交换_python