# 将序列分解为单独的变量-\*var

代码：

```python
records=[
    ('AAA',1,2),
    ('BBB','hello'),
    ('CCC',5,3)
]
def do_foo(x,y):
    print('AAA',x,y)

def do_bar(s):
    print('BBB',s)
# 迭代的records元素，取第一个，其余的变为*rest，意为可变长序列
for tag,*rest in records:
    if tag=='AAA':
        do_foo(*rest)
    elif tag=='BBB':
        do_bar(*rest)

line='guan:jing123://wef:678d:guan'
# 中间部分可辨长，头尾指定单独变量
uname,*fields,homedir,sh=line.split(':')
print(uname,homedir)
```

结果：

```python
AAA 1 2
BBB hello
guan 678d
```

视频：

```
wait
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://im-qianuxn.gitbook.io/pytorch/ji-suan-ji/python/2.2-shi-yong-yuan-zu/2.2.5-jiang-xu-lie-fen-jie-wei-dan-du-de-bian-liang.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
