我正在使用python中的請求模塊來獲取JSON響應中的某些字段。從Python App Annie解析此JSON響應
import json
fn = 'download.json'
data = json
response = requests.get('http://api.appannie.com/v1/accounts/1000/apps/mysuperapp/sales?break_down=application+iap&start_date=2013-10-01&end_date=2013-10-02', \
auth=('username', 'password'))
data = response.json()
print(data)
這工作在Python,作爲響應如下:
{ 'prev_page':無, '貨幣': 'USD', 'next_page':無, 'sales_list': ['收入':{'ad':'0.00','iap':{'refunds':'0.00','sales':'0.00','promotions':'0.00'},'app':{ 'refunds':'0.00','updates':'0.00','downloads':'0.00','promotions':'0.00'}}, 'units':{'iap':{'refunds':0 ,'sales':0,'promotions':0},'app':{'refunds':0,'updates':0,'downloads':2000,'promotions':0}},'country':' all','date':'all'}],'iap_sales':[],'page_num':1,'code':200,'page_index':0}
問題是我該如何解析這個來獲取我的下載數量在'app'塊中 - 即「2000」值?
正確地格式化您的代碼 –
data = json ???這應該怎麼做? –