Python_切片赋值

切片赋值

切片赋值时,多了会加,少了会补齐

 

>>> a = []
>>> a.append(1)
>>> a
[1]

切片赋值后,得到的结果

>>> a[0:1]=[1,2,3,4]
>>> a
[1, 2, 3, 4]
>>> a[0:2]=[1,2,3,4]
>>>

 

>>> a = [1]
>>> a = [1,2]
>>> a[0:2]=[1,2,3,4]
>>> a
[1, 2, 3, 4]
>>>
posted @ 2018-10-07 19:42  翻滚的小强  阅读(315)  评论(0编辑  收藏  举报