python的列表拷贝
Posted Carzy_Learner
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python的列表拷贝相关的知识,希望对你有一定的参考价值。
1.拷贝一个列表必须使用切片操作符拷贝看下面的结果,与预想之差异
print (\'Simple Assignment\')
shoplist = [\'apple\',\'mango\',\'carrot\',\'banana\']
mylist = shoplist
del shoplist[0]
print (\' shoplist is \', shoplist)
print (\'mylist is \' ,mylist)
print (\'Copy by making a full slice\')
mylist = shoplist[:]
del mylist [0]
print (\'shoplist is \',shoplist)
print (\'mylist is \',mylist)
以上是关于python的列表拷贝的主要内容,如果未能解决你的问题,请参考以下文章