V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2017-11-26 14:22:02 +08:00 · 6640 次点击
    这是一个创建于 2314 天前的主题,其中的信息可能已经有所发展或是发生改变。
    返回数据为

    {'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 条回复    2017-11-26 15:34:59 +08:00
    kyokuheishin
        1
    kyokuheishin  
       2017-11-26 14:39:58 +08:00   ❤️ 1
    把 json 转成字典然后多套几个[]取就是了
    est
        2
    est  
       2017-11-26 14:42:23 +08:00   ❤️ 2
    jres['data'][0]['bbb']
    mochanight
        3
    mochanight  
    OP
       2017-11-26 15:34:59 +08:00
    多谢楼上。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2017 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 16:18 · PVG 00:18 · LAX 09:18 · JFK 12:18
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.