python 拆包 装包
编程,Python (Programming, Python)
In this article, we will go through unpacking
, extended unpacking
& nested unpacking
. Let’s get started.
在本文中,我们将介绍unpacking
, extended unpacking
和nested unpacking
。 让我们开始吧。
开箱 (Unpacking)
The process of splitting the packed values into individual elements is called ‘unpacking
’. The packed values are strings, lists, tuples, sets, and dictionaries
.
将打包值拆分为单个元素的过程称为“ unpacking
”。 打包的值是strings, lists, tuples, sets, and dictionaries
。
During the unpacking elements from RHS
(Right Hand Side) are split into its relative position on the LHS
(Left Hand Side). We will see how this works in the following examples.
在拆箱过程中,来自RHS
(右手侧)的元件被分成其在LHS
(左手侧)上的相对位置。 在以下示例中,我们将了解其工作原理。
As we can see from the below two examples, elements from RHS
are unpacked into the variables on LHS
based on the relative position.
从下面的两个示例中可以看到, RHS
元素基于相对位置被解压缩到LHS