正如您所指出的,它们在功能上都是等价的.
可以使用逗号创建Python元组,使用括号作为描述它们的有用方法.
例如,请注意:
>>> x = 1,2,3
>>> print x, type(x)
(1, 2, 3)
>>> x = (1)
>>> print x, type(x)
1
>>> x = 1,
>>> print x, type(x)
(1,)
>>> x = (1,)
>>> print x, type(x)
(1,)
当您进行多次分配时,括号再次只定义优先级.
至于哪个最好,这取决于你的情况.
这可能还可以:
latitude, longitude = (23.000, -10.993)
这也是:
latitude, longitude = geo-point # Where geo point is (23.3,38.3) or [12.2,83.33]
这可能是矫枉过正:
first_name, last_name, address, date_of_birth, favourite_icecream = ... # you get the idea.