Indexes and Shards
>>> Wu = ' wuang '
>>> Wu[0]
' W '
>>> Wu[1]
' U '
>>> wu[1:]
' Uang '
>>> Wu[1:3]
' UA '
>>> Wu[-1]
' G '
>>> Wu[:-1]
' Wuan '
Index: Wu[i]
The first element has an offset of 0
[0]: first element
[-1]: last element
Shard Wu[i:j]
Upper boundary (i) does not contain
If I is not given, the default is 0
Wu[1:3]
Wu[:3]
WU[:-1]
wu[:]
Shards also have a limit value
Called Stepping
WU[I:J:K]
Offset to I until j-i, indexed once per k element
Wu[1:4:2]
The result is
>>> Wu[1:4:2]
' UN '
Every 2, i.e.
Wuang
U n
WU[::-1]
Step-in effect
Indicates that the Shard is right-to-left instead of left-to-right
A negative step is equivalent to a two-border reciprocal exchange
>>> Wu[::-1]
' Gnauw '
>>> ' Wuang ' [1:4]
' Uan '
>>> ' Wuang ' [Slice (1,4)]
' Uan '
>>> ' Wuang ' [::-1]
' Gnauw '
>>> ' Wuang ' [Slice (none,none,-1)]
' Gnauw '
This article is from the "Don't Ang" blog, please be sure to keep this source http://wuang.blog.51cto.com/9559762/1606442
Python sixth day (string-index and Shard)