擅长:python、mysql、java
<p>它有助于将字典缩进,以便更好地查看其嵌套:</p>
<pre><code>mydict = {
'items': [
{
'id': '12345',
'links': {'self': 'https://www.google.com'},
'name': 'beast',
'type': 'Device'
}
],
'links': {'self': 'https://www.google.com'},
'paging': {
'count': 1,
'limit': 1,
'offset': 0,
'pages': 1
}
}
</code></pre>
<p>现在您可以提取所需内容:</p>
<blockquote>
<p>If I want to get "id", "self", "name",</p>
</blockquote>
<pre><code>print(mydict['items'][0]['id'])
print(mydict['items'][0]['links']['self'])
print(mydict['links']['self'])
print(mydict['items'][0]['name'])
</code></pre>