变量的交换
解释
a = "hello"
b = "world"
交换a和b的值
预期结果:a = "world" b = "hello"
`
方式一:python特性a,b交换
a = "hello"
b = "world"
a,b = b,a
print("交换后的a:%s" %a)
print("交换后的a:%s" %b)
方式二,使用第三个变量交换
a = "hello"
b = "world"
c = a
a = b
b = c
print("交换后的a",a)
print("交换后的b",b)