我是 Python 新手(上周),已经达到了我的极限。花了三天时间,我大部分时间都在stackoverflow上,但我不知道如何走得更远!
Json有多个嵌套数组。它可以包含三个(如下例 (json.txt) 所示)或 30 个。我需要遍历每个,然后深入到“局”,最后得到“小门”的值。这是我感到困惑的最后一步。任何人都可以建议吗?
你完全绝望
将要
import os, json,requests
print 'Starting'
url = 'https://dl.dropboxusercontent.com/u/3758695/json.txt'
# download the json string
json_string = requests.get(url)
print 'Downloaded json'
# get the content
the_data = json_string.json()
print 'the_data has length ', len(the_data)
for index in range(len(the_data)):
print 'Now working on index ', index
for wicket in the_data[index]:
print 'wicket equals ',wicket
# OK - I can see Innings. Now, how do I get inside
# and obtain 'wickets'?