`
dxm1986
  • 浏览: 429608 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

python list copy and reference

阅读更多

#!/usr/bin/python
# Filename: reference.py


print 'Simple Assignment'
shoplist = ['apple''mango''carrot''banana']
mylist = shoplist # mylist is just another name pointing to the same object!

del shoplist[0]

print 'shoplist is', shoplist
print 'mylist is', mylist
# notice that both shoplist and mylist both print the same list without
# the 'apple' confirming that they point to the same object


print 'Copy by making a full slice'
mylist = shoplist[:] # make a copy by doing a full slice
del mylist[0# remove first item

print 'shoplist is', shoplist
print 'mylist is', mylist
# notice that now the two lists are different

 

 

 

 

 

分享到:
评论

相关推荐

    The Python Quick Syntax Reference

    The Python Quick Syntax Reference is the “go to” book that contains an easy to read and use guide to Python programming and development. This condensed code and syntax reference presents the Python ...

    Python.Pocket.Reference.pdf

    designations, Python Pocket Reference, the image of a rock python, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to ...

    Python_Pocket_Reference_(5th_edition)

    Python_Pocket_Reference_(5th_edition) Python_Pocket_Reference_(5th_edition)

    Python.Pocket.Reference(5th,2014.1)

    This pocket reference summarizes Python types and statements, special method names, built-in functions and exceptions, com‐ monly used standard library modules, and other prominent Python tools. It ...

    python中copy()与deepcopy()的区别小结

    接触python有一段时间了,一直没有系统的学习过,也对copy,deepcoy傻傻的分不清,故抽出时间来理一下。 下面这篇文章主要给大家介绍了关于python中copy()与deepcopy()的区别的相关资料,需要的朋友可以参考下

    Python_Pocket_Reference

    This pocket reference summarizes Python types and statements, special method names, built-in functions and exceptions, commonly used standard library modules, and other prominent Python tools. It is ...

    python-copy函数用法.docx

    python copy函数用法 Python中的copy函数是一个非常有用的函数,它可以用来复制一个对象。在Python中,对象可以是任何东西,包括列表、元组、字典等等。copy函数可以将一个对象复制到另一个对象中,这样我们就可以在...

    Python Data Structures and Algorithms [2017]

    Python Data Structures and Algorithms by Benjamin Baka English | 30 May 2017 | ASIN: B01IF7NLM8 | 310 Pages | AZW3 | 6.63 MB Key Features A step by step guide, which will provide you with a thorough...

    python的copy方法.docx

    python的copy方法 Python的copy方法是一个非常有用的函数,它可以用来复制一个对象。在Python中,对象是指任何可以被赋值给一个变量的东西,包括数字、字符串、列表、元组、字典等等。当我们需要复制一个对象时,...

    Python.Essential.Reference

    THIS BOOK IS INTENDED TO BE A CONCISE REFERENCE to the Python programming language.Although an experienced programmer will probably be able to learn Python from this book, it’s not intended to be an ...

    Python Pocket Reference 2009 (epub 格式)

    This pocket reference summarizes Python types and statements, special method names, built-​in functions and exceptions, commonly used standard library modules, and other prominent Python tools. ...

    python-3.6.1 Reference Manual

    python-3.6.1 Reference Manual 英文 PDF

    Python 2.4 Quick Reference Card

    Python 2.4 Quick Reference Card,Laurent制作。

    Python for Data Mining Quick Syntax Reference

    This book provides you with a handy reference and tutorial on topics ranging from basic Python concepts through to data mining, manipulating and importing datasets, and data analysis. Python for Data...

    Tkinter 8.5 reference: a GUI for Python

    Describes the Tkinter widget set for constructing graphical user interfaces (GUIs) in the Python programming language. Includes coverage of the ttk themed widgets. John W. Shipman

    使用python list 查找所有匹配元素的位置实例

    如下所示: import re word = test s = test abcdas test 1234 testcase testsuite ... 您可能感兴趣的文章:Python 查找list中的某个元素的所有的下标方法python 获取list特定元素下标的实例讲解python

    Python Essential Reference 4th 原版PDF by Beazley

    This book is intended to be a concise reference to the Python programming language. Although an experienced programmer will probably be able to learn Python from this book, it’s not intended to be an...

    python 复制copy图像和转png格式

    python 复制copy图像和转png格式, 利用python 复制copy图像和转png格式

    Python Essential Reference.2009_python_

    Python Essential Reference 2009

Global site tag (gtag.js) - Google Analytics