方法1:(错误)
def func(a,b): a,b = b,a a = 1 b = 2 func(a,b) print(a," ",b)
方法2:(正确)
def func(a,b): return b,a a = 1 b = 2 a,b = func(a,b) print(a," ",b)