List (one-dimensional array) chips
Syntax:
List [start Index: terminate Index: step]
Slice assignment list:
action:
may change the original list, can insert and delete data, the data may be changed
Description:
right equals operator slice assignment must be a sequence
Syntax:
List [(start index) :( termination index ) (step :())] = sEQUENCE
Definitions:
For the step size of the slice assigned a sequence number equal to the number of cut out sections
s [i: j] represents obtain a [i] to a [j-1]
s [: - 1] to remove the last character
s [: - n] to remove the last n characters
s [-2:] Take last two characters
s [i: j: k] format it, i, j and the same as above, but represents a step k, the default is 1
s [:: - 1] is copied from the last element to the first element again (reverse)
Two-dimensional array slice
X [:, 0] 0 take the first data for all rows, the second dimension bit index data of all 0, the first 0 (zero)
X [:, 1] take the first data for all rows
X [:, 1:] All first dimension taken, i.e. all the rows, columns taken from the first column starts, not the first 0
X [1 ,:] The first dimension was taken as the index for all data elements 1, line 1 (starting with 0)
X [: 2,1:] before the first remove the standard two-dimensional, i.e. before the second row (two rows 0,1), begins to take on a column from the first column, not 0th column
Three-dimensional array slice
U [1,1,2] take a first dimension, a second dimension taken 1, a third dimension taken 2
U [:, 1,2] indicates a first dimension to take all, take a second dimension, third dimension taken 2
U [:, 1:, 2] first dimension to take all the second dimension after taking all the values 1 and 1, a third dimension taken 2
U [:, 1:,: 2] to take all the first dimension, the second dimension after taking all the values 1 and 1, the third dimension takes a value before 2 (0,1)
Description:
And so on multidimensional arrays, the comma "," to separate each dimension ":" represents a slice in each dimension only: it represents the total value of taking this dimension