Decompression sequence
Example 1: The left value must be the same as the value on the right one by one, or it will be an error
1 >>> a,b,c={1,2,3} #a =1,b=2,c=32 >>> a3 14 >>> b5 26 >>> C7 3
Example 2: The left value must be the same as the value on the right one by one, or it will be an error
1>>> a,b,c,d,e='Hello' #decompression sequence, the left value must be the right value is one by one corresponding to the relationship, or will error2>>>a3 'h'4>>>b5 'e'6>>>C7 'L'8>>>D9 'L'Ten>>>e One 'o'
Example 3:
Take the first and last value of a list
1 >>> l=[10,3,2,3,5,1,2,3,5,8,9]2 >>> a,*_,c=l #取第一个值和最后一个值 3 >>> a4 5 >>> C6 9
Example 4:
The value of a, B interchange position
1 # the value of a, B interchange position 2 3 >>> a=1 4 >>> b=2 5 6 >>> x=a 7 >&G t;> x 8 1 9 >>> a=b >>> b=x One >>> a b (2, 1)
Example 5: Exchanging values for F1 and F2
1 # exchanging values for F1 and F2 2 3 >>> f1=1 4 >>> f2=2 5 6 7 >>> f1,f2=f2,f1< /c9> 8 >>> F1 9 2 >>> f2 1
Python Basics-Unzip sequence