python - 如何使用python多字典中的键获取值

标签 python json dictionary

{
 "card_quota": 0,
 "custom_data": "{\"child_name\":\"홍설\",\"uid\":\"29\",\"lid\":\"56\",\"count\":\"1\",\"schedule\":\"2016-06-18(토)\"}",
 "escrow": false
}

这是Python的字典类型。我知道使用像 temp['card_quata'] 这样的代码来获取值(value)。但我想知道在 ['custom_data'] 中使用 key 获取 child_name 或 uid 等值..我该怎么做?

最佳答案

您可以使用 json.loads 解析 custom_data然后访问返回的dict:

>>> import json
>>> json.loads(temp['custom_data'])['child_name']
'홍설'

请注意,您提供的示例数据不是有效的 Python,因为 Python 使用 False 而不是 false

关于python - 如何使用python多字典中的键获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37827133/

相关文章:

python - pandas,计算每组的值?

python - 长整数的最大值

python - 如何在构建过程中安装私有(private) Python 包

python - Iterable Datetime - 如何在 Python 中获取具有日期名称的连续日期时间对象?

python - 如何让字典打印出随机键

python - Pandas - 从日期时间中提取日期,如果时间超过某个小时则加一天

.net - .Net 微框架的 Json 库

jquery - 如何使用 GM_xmlhttpRequest 将序列化数组从客户端表单获取到服务器

iphone - 在 iOS 中谷歌查询经度和纬度时没有得到 json 响应?

python - 在一个 dict 的 dict 中,你如何模拟 Perl 的自动激活行为?