首页 > 代码库 > python 解析 json

python 解析 json

#coding=utf=8import urllib,jsonurl =‘https://api.douban.com/v2/book/user/62855846/collections‘read = urllib.urlopen(url).read()j = 0titles=[]atls=[]images=[]a = json.loads(read)leng = int(a[‘total‘])for i in range(leng):    titles.append( a[‘collections‘][j][‘book‘][‘title‘])    atls.append(a[‘collections‘][j][‘book‘][‘alt‘])    images.append( a[‘collections‘][j][‘book‘][‘images‘][‘medium‘])       j=j+1    print titlesprint atlsprint images