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)

 

posted @ 2017-11-20 20:20  Carzy_Learner  阅读(214)  评论(0编辑  收藏  举报