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

萌新求助 Python 如何获取嵌套 json 的值?

  •  
  •   mochanight · Nov 26, 2017 · 7326 views
    This topic created in 3257 days ago, the information mentioned may be changed or developed.
    返回数据为

    {'retCode': '0000000', 'retMsg': '查询成功', 'data': [{'aaa': '111', 'bbb': '222', 'ccc': '333', 'ddd': '444', 'eee': '555', 'fff': '666', 'ggg': '777', 'hhh': None}]}


    jres = json.loads(a.text)

    jres['retCode'] 可以获取到 0000000.
    问一下如何获取到 data 下面 bbb 的值?
    3 replies  •  2017-11-26 15:34:59 +08:00
    kyokuheishin
        1
    kyokuheishin  
       Nov 26, 2017   ❤️ 1
    把 json 转成字典然后多套几个[]取就是了
    est
        2
    est  
       Nov 26, 2017   ❤️ 2
    jres['data'][0]['bbb']
    mochanight
        3
    mochanight  
    OP
       Nov 26, 2017
    多谢楼上。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2018 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 16:45 · PVG 00:45 · LAX 09:45 · JFK 12:45
    ♥ Do have faith in what you're doing.