Python 将JSON另存为字典

Python 将JSON另存为字典,python,json,api,dictionary,parsing,Python,Json,Api,Dictionary,Parsing,我是python新手,我只需要从API输出中提取电子邮件到JSON格式 示例:“电子邮件”:brucelee@.....“目前,我将代码添加到列表中,主要是因为我很难将其输出到字典或其他我可以使用的东西中。提前感谢您的帮助 {'account_locked': None, 'activated': None, 'addresses': None, 'allow_public_key': None, 'attributes': None, 'bad_login_attempts': No

我是python新手,我只需要从API输出中提取电子邮件到JSON格式

示例:“电子邮件”:brucelee@.....“目前,我将代码添加到列表中,主要是因为我很难将其输出到字典或其他我可以使用的东西中。提前感谢您的帮助

{'account_locked': None,
 'activated': None,
 'addresses': None,
 'allow_public_key': None,
 'attributes': None,
 'bad_login_attempts': None,
 'company': None,
 'cost_center': None,
 'created': None,
 'department': None,
 'description': None,
 'displayname': None,
 'email': 'adasda@asdasda'}

您只需执行以下操作即可获得电子邮件:

api_response1 = api_instance.systemusers_get(id, content_type, accept, fields=fields, filter=filter, x_org_id=x_org_id)

import json
jsondata = json.loads(api_response1)
email = jsondata['email']

这应该能回答你的问题——小问题,但“储蓄”这个词在这里有点奇怪。通常,在反向过程中可以使用saving一词,在反向过程中,您希望将对象序列化为json,以便将其轻松保存到文件中,反向操作将被称为反序列化。列表有什么问题?如果您只想提取电子邮件,那么最终会得到一个电子邮件列表。dict需要一些辅助信息(如键或值),这样您就不会只收到所需的电子邮件。
api_response1 = api_instance.systemusers_get(id, content_type, accept, fields=fields, filter=filter, x_org_id=x_org_id)

import json
jsondata = json.loads(api_response1)
email = jsondata['email']