推荐学习书目
› 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 · 7348 views
    This topic created in 3268 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
    kyokuheishin
    Nov 26, 2017❤️1
    1
    把 json 转成字典然后多套几个[]取就是了
    est
    est
    Nov 26, 2017❤️2
    2
    jres['data'][0]['bbb']
    mochanight
    mochanight
    OP
    Nov 26, 2017
    3
    多谢楼上。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1736 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 147ms · UTC 14:20 · PVG 22:20 · LAX 06:20 · JFK 09:20
    ♥ Do have faith in what you're doing.