元组解构

# 元组解构
t = (1, 2, 3)
a, b, c = t
print(a)  # 输出: 1
print(b)  # 输出: 2
print(c)  # 输出: 3

列表解构

# 列表解构
l = [4, 5, 6]
x, y, z = l
print(x)  # 输出: 4
print(y)  # 输出: 5
print(z)  # 输出: 6

字典解构

# 字典解构
d = {'name': 'Alice', 'age': 30}
name, age = d['name'], d['age']
print(name)  # 输出: Alice
print(age)   # 输出: 30

剩余元素解构

# 剩余元素解构
numbers = (1, 2, 3, 4, 5)
first, *rest, last = numbers
print(first)  # 输出: 1
print(rest)   # 输出: [2, 3, 4]
print(last)   # 输出: 5