tuple unpacking

拆开Tuple

lax_coordinates = (33.9425, -118.408056)
latitude, longitude = lax_coordinates # tuple unpacking

交换位置

variable = (10,20) # a = 10, b = 20
b,a = variable
print ("a = %d, b = %d" % (a,b))

使用Tuple可以方便的交换两个数的位置,不用设临时变量。

原文地址:https://www.cnblogs.com/yaos/p/14014290.html