码迷,mamicode.com
首页 > 编程语言 > 详细

Python提取json数据

时间:2019-02-23 13:27:29      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:输出   san   user   proc   .exe   with   process   data   python   

import json jsonstring = ‘{"user_man":[{"name":"Peter"},{"name":"xiaoming"}],"user_woman":[{"name":"Anni"},{"name":"zhangsan"}]}‘ print(json_data) print(json_data[‘user_man‘]) print(json_data[‘user_woman‘]) print(json_data[‘user_man‘][0]) print(json_data[‘user_man‘][1]) print(json_data[‘user_man‘][0][‘name‘]) print(json_data[‘user_man‘][1][‘name‘])

输出:

D:\Python\venv\Scripts\python.exe D:/Python/venv/test10.py
{‘user_man‘: [{‘name‘: ‘Peter‘}, {‘name‘: ‘xiaoming‘}], ‘user_woman‘: [{‘name‘: ‘Anni‘}, {‘name‘: ‘zhangsan‘}]}
[{‘name‘: ‘Peter‘}, {‘name‘: ‘xiaoming‘}]
[{‘name‘: ‘Anni‘}, {‘name‘: ‘zhangsan‘}]
{‘name‘: ‘Peter‘}
{‘name‘: ‘xiaoming‘}
Peter
xiaoming

Process finished with exit code 0

Python提取json数据

标签:输出   san   user   proc   .exe   with   process   data   python   

原文地址:https://blog.51cto.com/12884584/2353779

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!