Skip to content

修改部分翻译 #290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions source/c01/p01_unpack_sequence_into_separate_variables.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
===============================
1.1 解压序列赋值给多个变量
1.1 将序列分解为单独的变量
===============================

----------
Expand All @@ -10,8 +10,8 @@
----------
解决方案
----------
任何的序列(或者是可迭代对象)可以通过一个简单的赋值语句解压并赋值给多个变量
唯一的前提就是变量的数量必须跟序列元素的数量是一样的
任何的序列(或者是可迭代对象)可以通过一个简单的赋值操作来分解为单独的变量
唯一的要求就是变量的总数和结构必须与序列相吻合

代码示例:

Expand Down Expand Up @@ -41,7 +41,7 @@
21
>>>

如果变量个数和序列元素的个数不匹配,会产生一个异常
如果元素的数量不匹配,会得到一个错误提示

代码示例:

Expand All @@ -57,7 +57,7 @@
----------
讨论
----------
实际上,这种解压赋值可以用在任何可迭代对象上面,而不仅仅是列表或者元组
不仅仅只是元组或列表,只要对象是可迭代的,就可以执行分解操作
包括字符串,文件对象,迭代器和生成器。

代码示例:
Expand Down