V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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 · 4523 views
    This topic created in 4364 days ago, the information mentioned may be changed or developed.
    学一门就相当于会两门,这不是赚大发了吗?
    4 replies
    pacino
        1
    pacino  
       May 18, 2014
    恭喜你~
    unionx
        2
    unionx  
       May 18, 2014
    不一样哦
    est
        3
    est  
       May 18, 2014
    a = {None: u'haha'}
    bravluna
        4
    bravluna  
       May 18, 2014
    这是你的重大发现吗?
    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   ·   Solana   ·   907 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 21:04 · PVG 05:04 · LAX 14:04 · JFK 17:04
    ♥ Do have faith in what you're doing.