推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
Livid
396.81D
544.61D
V2EX  ›  Python

关于 Python 里 tuples 和 list 的区别

  •  
  •   Livid ·
    PRO
    · Aug 11, 2012 · 8511 views
    This topic created in 5163 days ago, the information mentioned may be changed or developed.
    4 replies  •  1970-01-01 08:00:00 +08:00
    tywtyw2002
        1
    tywtyw2002  
       Aug 11, 2012
    一个可以修改 一个不能修改
    Livid
        2
    Livid  
    MOD
    OP
    PRO
       Aug 11, 2012
    @tywtyw2002 而且 tuples 可以作为 dict 的 key。
    beiye
        3
    beiye  
       Aug 11, 2012
    @Livid 其实就是1楼说的
    因为不可修改,才是hashable的,然后才能当作dict的key,同样set也是必须能够hashable
    比如list就不能放到set里面去
    phay
        4
    phay  
       Aug 11, 2012
    hashable和immutable有关联只是为了hash时有O(1)的效率。自定义容器,提供__hash__, __cmp__即可。。效率自己控制。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1005 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 18:21 · PVG 02:21 · LAX 11:21 · JFK 14:21
    ♥ Do have faith in what you're doing.