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

python 有没类似 php 一样的关联数组写法

  •  
  •   617450941 · Nov 29, 2015 · 4052 views
    This topic created in 3842 days ago, the information mentioned may be changed or developed.
    貌似 python 的 list 只有索引方式访问 list 内的元素 不能对元素进行定义名称
    12 replies    2015-12-05 08:40:47 +08:00
    pynix
        1
    pynix  
       Nov 29, 2015
    字典是吃干饭的吗?
    Slienc7
        2
    Slienc7  
       Nov 29, 2015
    dict
    saxon
        3
    saxon  
       Nov 29, 2015
    @pynix 楼上的头像是 Ruby 么。。。
    knktc
        4
    knktc  
       Nov 29, 2015
    你说的是有序字典? collections.OrderedDict ?
    pynix
        5
    pynix  
       Nov 29, 2015
    @saxon 是的,自己做的, svg 已丢失。。。。
    irgil
        6
    irgil  
       Nov 29, 2015
    php 中的关联数组实际上就是一个简化版的 map ,所以用 python 中的 dict 就可以
    matthewz
        7
    matthewz  
       Nov 29, 2015
    或者 namedtuple 其实就是个简单的 class
    LINAICAI
        8
    LINAICAI  
       Nov 29, 2015
    楼主认真看过 php 和 python 的语法?
    Changxu
        9
    Changxu  
       Nov 29, 2015
    LZ 你真的自以为学过 Python ?
    ChiChou
        10
    ChiChou  
       Nov 29, 2015
    what = {"is": "this"}
    XianZaiZhuCe
        11
    XianZaiZhuCe  
       Dec 1, 2015
    @Changxu 请尽量让自己的回复能够对别人有帮助
    617450941
        12
    617450941  
    OP
       Dec 5, 2015 via Android
    @LINAICAI 就是不知道才问呀
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2681 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 10:25 · PVG 18:25 · LAX 03:25 · JFK 06:25
    ♥ Do have faith in what you're doing.