Decoding nested JSON with multiple 'for' loops

后端 未结 3 1189

I\'m new to Python (last week), and have reached my limit. Spent three days on this, most of my time in stackoverflow, but I cannot work out how to go any further!

T

3条回答
  •  忘掉有多难
    2021-01-16 15:47

    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 d in the_data[index]['innings']:
            print d['wickets']
    

提交回复
热议问题