推荐学习书目
› 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
yakczh
V2EX  ›  Python

python 的 list 和 dict 跟 js 的 Array Object 语法竟然一样

  •  
  •   yakczh · May 18, 2014 · 4908 views
    This topic created in 4556 days ago, the information mentioned may be changed or developed.
    学一门就相当于会两门,这不是赚大发了吗?
    4 replies
    pacino
    pacino
    May 18, 2014
    1
    恭喜你~
    unionx
    unionx
    May 18, 2014
    2
    不一样哦
    est
    est
    May 18, 2014
    3
    a = {None: u'haha'}
    bravluna
    bravluna
    May 18, 2014
    4
    这是你的重大发现吗?
    1,list 不能是稀疏的,且不能超出索引赋值,增长只能用『+』或 append();array 可以是稀疏的,可以给任意索引赋值
    2,dict 的键可以是个不可变的对象,比如 {(None,): 1},Object 的键只有一种:字符串
    3,JS 里 array 其实就是个 Object 哦,var ary = [1, 2, 3]; ary["1"] = null; 于是 ary 变成了 [1, null, 3]
    结论:不一样的地方比一样的地方更多!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1665 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 11:11 · PVG 19:11 · LAX 03:11 · JFK 06:11
    ♥ Do have faith in what you're doing.