赋值与解包
# python3.6.8
x, y = (1, 2)
print(x, y) # 1 2
x, y = (1, 2, 3)
print(x, y) # ValueError: too many values to unpack (expected 2)
x, *y = (1, 2, 3)
print(x, y) # 1 [2, 3]
x, *y, z = (1, 2, 3, 4)
print(x, y, z) # 1 [2, 3] 4
# python3.6.8
x, y = (1, 2)
print(x, y) # 1 2
x, y = (1, 2, 3)
print(x, y) # ValueError: too many values to unpack (expected 2)
x, *y = (1, 2, 3)
print(x, y) # 1 [2, 3]
x, *y, z = (1, 2, 3, 4)
print(x, y, z) # 1 [2, 3] 4