Summary of knowledge points about Python unpacking

**Unpack **

It is called Unpacking in English, which means to take out the elements in the container one by one and put them elsewhere. It is like your parents go to the vegetable market to buy a bag of apples and send them to each member of the family. This process is unpacking. Unpacking in Python is done automatically, for example:

student =['xiaoqiang','man','22']
name,sex,age = student
print(name,sex,age)
Result: xiaoqiang man 22

If there are 3 elements in the list, they can be assigned to 3 variables. In addition to list objects that can be unpacked, any iterable object supports unpacking. Iterable objects include tuples, dictionaries, sets, strings, generators, etc., all objects that implement the next method.

Knowledge point expansion:

Sequence unpacking example:

 a, b, c =1,2,3
 a
1
 b
2
 c
3

Nested unpacking example

( a, b),(c, d)=(1,2),(3,4)
 a
1
 b
2
 c
3
 d
4
 a, b, c,d(1,2,3,4)

So far this article on the summary of Python unpacking knowledge points is introduced. For more detailed explanations of Python unpacking, please search for ZaLou.Cn's previous articles or continue to browse related articles below. I hope you will support ZaLou more in the future. Cn!

Recommended Posts

Summary of knowledge points about Python unpacking
Python knowledge points
Knowledge points of shell execution in python
Python3 supplementary knowledge points
Python advanced knowledge points
Basic knowledge of Python (1)
2020--Python grammar common knowledge points
Summary of logarithm method in Python
Python crawler basic knowledge points finishing
A summary of 200 Python standard libraries!
Summary of Python calling private attributes
​Full analysis of Python module knowledge
Summary of common operations of Python time module
Summarize the knowledge points of Centos7 system reinforcement
7 features of Python3.9
How about learning python at the age of 27?
Python basic summary
A brief summary of the difference between Python2 and Python3
Talking about Python coroutine
Python processing json summary
Python interview questions summary
Basics of Python syntax
Python advanced usage summary
Basic syntax of Python
Learn about Python3 coroutine
Prettytable module of python
09. Common modules of Python3
Summary of ubuntu usage