Python unpacking and packaging

Python unpacking and packaging

The number of variables is inconsistent with the number of tuples
Insert picture description here
Insert picture description here

For example:
t3 = (3,6,7,5,9,8,3)
a,*b = (3,6,7,5,9,8,3)
1. Python interpreter bottom layer: 3, 6,7,5,9,8,3
2. Assignment
a = 3
*b = 6 7 5 9 8 3 The
bottom layer has the symbol ※, ※ b = 6 7 5 9 8 3 -----> [6, 7,5,9,8,3], here, the bottom layer has done a package operation. And assign (packaging) the list value to b.

3. Print
*b in the print indicates the unpacking operation.

The code is as follows: Application
Insert picture description here
Insert picture description here
in variable parameters and keyword parameters. When
calling func (**dict1), ** represents unpacking
. When defining functions, **kwargs represents packaging, assembled into a dictionary
Insert picture description here

Insert picture description here

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_44994799/article/details/109681204