Indexes and Shards:
1. Index: s[j] Gets the element with a specific offset
Note: Offsets have positive and negative offsets
Negative offsets are counted in reverse from the last or the right.
The negative index number plus the length of the string equals the position of the positive offset
2, the common method of sharding:
S[I:J] means, starting from the element I position, to the end of J position, which does not include the first J element (left closed right open)
S[1:] Gets all elements from the beginning of the offset to 1, including the 1 position
S[:3] Gets the element that starts with a 0 offset to an offset of 3, not including the 3 position
S[:-1] Gets all elements that begin with a 0 offset, not including the last element
s[:] Copy entire string
3, Extended shard, third limit value:
python2.3, the Shard expression adds an optional third index, which is used as a stepping
S[x:y:z] means, starting from the X position, to the position element with the offset Y (excluding the Y position), where the element with the interval Z is taken out
4. Shard Object Slice ()
>>>s = ' spam '
>>>s[1:3]
>>> ' Pa '
>>>s[slice (1,3)]
>>> ' Pa '
5, the role of sharding:
(1) A Shard expression can return a list of all elements except the first one
(2) Clean up the contents of the input file