Split sequence python

  And a variable number of sequence length is equal to

   Assignment statement sequence may be split, and then assigned to a plurality of variables, the following form:

   Variable 1, variable 2, ..., n = variable sequences or iterables

   If the number of variables and inconsistency number of elements in the sequence will cause a ValueError, for example:

   

 

  And a variable number of sequences of unequal length 2

   If the sequence length is not known, may be used tuples * variables, the plurality of values ​​assigned to the variable as a tuple of tuples, in an assignment statement, the variables * a tuple allows only appears once, otherwise cause SyntaxError. E.g:

  

 

  3 Use temporary variables _

    If only part of the data, the sequence may be used in other locations _ temporary variables, for example:

  

Guess you like

Origin www.cnblogs.com/xiaohaodeboke/p/12132993.html