>>> # Replace some items:
... a[0:2= [112]
>>> a
[
1121231234]
>>> # Remove some:
... a[0:2= []
>>> a
[
1231234]
>>> # Insert some:
... a[1:1= ['bletch''xyzzy']
>>> a
[
123'bletch''xyzzy'1234]
>>> # Insert (a copy of) itself at the beginning
>>> a[:0] = a
>>> a
[
123'bletch''xyzzy'1234123'bletch''xyzzy'1234]
>>> # Clear the list: replace all items with an empty list
>>> a[:] = []
>>> a
[]

相关文章: