替换某一段:把0-1区间的值替换成[‘A’,‘B’,‘C’,‘D’]
a=[1,2,3,4,5]
a[0:2]=['A','B','C','D']
print(a)
结果
['A', 'B', 'C', 'D', 3, 4, 5]
删除这一段
a=[1,2,3,4,5]
a[0:2]=[]
print(a)
结果:
[3, 4, 5]
替换某一段:把0-1区间的值替换成[‘A’,‘B’,‘C’,‘D’]
a=[1,2,3,4,5]
a[0:2]=['A','B','C','D']
print(a)
结果
['A', 'B', 'C', 'D', 3, 4, 5]
删除这一段
a=[1,2,3,4,5]
a[0:2]=[]
print(a)
结果:
[3, 4, 5]