1.1 将固定序列分解为单独的变量
类似于
p = (4,5)
x, y = p
print(x, y)
# 4 5
```python
a = b = 1
print(a, b)
# 1 1
# 字符串也是可迭代的序列
sentence = 'hello!'
a, b, c, d, e, f = sentence
print(a, b, c, d, e, f)
# h e l l o !
# 可以使用"_"占位
sentence = 'hello!'
_, b, c, d, e, _ = sentence
print(b, c, d, e)
# e l l o'''
1.2 将不定长序列分解为单独的变量
可解决too many values to unpack的错误
使用""占位,加的变量一直是一个列表
# 在最后
sentence = 'hello!'
a, *b = sentence
print(a, b)
# h ['e', 'l', 'l', 'o', '!']
#在最前
sentence = 'hello!'
*a, b = sentence
print(a, b)
# ['h', 'e', 'l', 'l', 'o'] !
#在中间
sentence = 'hello!'
a, *b, c = sentence
print(a, b, c)
# h ['e', 'l', 'l', 'o'] !
# 实例
record = ['ACM', 20, 45, 100, (12, 18, 2000)]
name, *_, (*_, year) = record
print(name, year)
# ACM 2000'''