Tuple basis

Tuple (tuple)
Tuple is an immutable sequence, and its operation is basically the same as that of a list (that is, it cannot be modified)
. Tuple is used when the data is not changed, and the rest is
created with a list : ()
If the tuple is not empty Then there is at least one in the tuple, such as (the following example is a special case)
Insert picture description here
Insert picture description here

The usual situation is Insert picture description hereunpacking : assign each element in the tuple to each variable (the number of elements must be equal to the number of variables)
Insert picture description here

If not equal, then the number Insert picture description here
can be added in front of the variable to solve Insert picture description here
Insert picture description herenot added
to the variable positions will tuple related elements correspond, but preceded by the variable will correspond to those extra elements (in the form of a list) , But there cannot be two

Guess you like

Origin blog.csdn.net/weixin_51864831/article/details/109613920