方法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)
原文地址:https://www.cnblogs.com/luojianyi/p/9573990.html
时间: 2024-11-12 05:58:56
方法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)
原文地址:https://www.cnblogs.com/luojianyi/p/9573990.html