更新时间:2023-01-17 08:31:22
我没有意识到第一个嵌套元素实际上是一个数组.正确访问邮政编码密钥的方法如下:
I did not realize that the first nested element is actually an array. The correct way access to the post code key is as follows:
r = requests.get('http://api.zippopotam.us/us/ma/belmont')
j = r.json()
print j['state']
print j['places'][1]['post code']