我正在从网址阅读文件,格式如下
[{
"Coupon_ID": "IW12390",
"Campaign_ID": "353",
"Campaign_Name": "Dominos",
"Title": "Get 10% Off on INR 400",
"Description": "Get 10% Off on INR 400 & Above. Valid for online order only. This code is not valid on Simply Veg, Simply N-Veg Pizzas, and Combos.",
"Category": "Food & Beverages",
"Type": "Coupon",
"Type_Value": "DOM10",
"Tracking_URL": "http:\/\/tracking.icubeswire.com\/aff_c?offer_id=353&aff_id=1784",
"Added_Date": "2017-02-01",
"Expiry_Date": "2017-02-07"
},{
"Coupon_ID": "IW12392",
"Campaign_ID": "2269",
"Campaign_Name": "Shoppers Stop",
"Title": "Flat 50% on Fratini Woman",
"Description": "Flat 50% on Fratini Woman only at Shoppers Stop. So Hurry!\r\n\r\n",
"Category": "E-Commerce",
"Type": "Deal",
"Type_Value": "None",
"Tracking_URL": "http:\/\/tracking.icubeswire.com\/aff_c?offer_id=2269&aff_id=1784&url_id=16740",
"Added_Date": "2017-01-05",
"Expiry_Date": "2017-02-01"
},]
现在我想要像这样的列表变量的值。我的意思是 我需要将值转储到变量X. print X应该与input和
相同x[0] - first dict
x[1] - 2nd dict like that..
我使用了python urllib和jSon等。没有用。
我试过的代码
import json,urllib;
f = urllib.urlopen("http://assets.icubeswire.com/dealscoupons /api/getcoupon.php?API_KEY=365dx177x70080ce8b07a05e47ae79118d8641")
x = json.load(f)
#API key changed that is not correct in that code.. just try with sample input