list索引和分片都是原地修改
>>> a='sdfsd'
>>> id(a)
32030656
>>> b=list(a)
>>> id(b)
31987112
>>> b[0]='x'
>>> id(b)
31987112
>>> b[1]='fsadfsa'
>>> b
['x', 'fsadfsa', 'f', 's', 'd']
>>> b[1:3]=['1211','43534']
>>> b
['x', '1211', '43534', 's', 'd']
>>> id(b)
31987112
list方法调用
>>> b
['x', 'sdfsaf', 's', 'd']
>>> b.append('asdfsad')
>>> id(b)
31987112
>>> b.sort()
>>> id(b)
31987112
>>> b
['asdfsad', 'd', 's', 'sdfsaf', 'x']
>>> b.pop()
'x'
>>> id(b)
31987112
>>> b.reverse()
>>> id(b)
31987112
>>> b.insert (2,'afsdfsfssssss')
>>> b
['sdfsaf', 's', 'afsdfsfssssss', 'd', 'asdfsad']
>>> id(b)
31987112
>>> del b[1]
>>> b
['sdfsaf', 'afsdfsfssssss', 'd', 'asdfsad']
>>> id(b)
31987112
将[]赋值给b[i:j]会删除对应的分片,但是如果将[]赋值给一个索引只会的指定的位置存储空列表的引用
>>> b[1:2]=[]>>> b
['sdfsaf', 'd', 'asdfsad']
>>> b[1]=[]
>>> b
['sdfsaf', [], 'asdfsad']
>>>