首页 > 编程语言 > 详细

python的列表拷贝

时间:2017-11-20 20:49:22      阅读:224      评论:0      收藏:0      [点我收藏+]

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的列表拷贝

原文:http://www.cnblogs.com/dadaozhijian22/p/7868079.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!