首页 > 代码库 > 列表分片

列表分片

>>> t=range(10)
>>> t
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> t[1:4]=[‘a‘]
>>> t
[0, ‘a‘, 4, 5, 6, 7, 8, 9]
>>> t[2:2]=[]
>>> t
[0, ‘a‘, 4, 5, 6, 7, 8, 9]
>>> t[2:3]=[]
>>> t
[0, ‘a‘, 5, 6, 7, 8, 9]

列表分片