Chinaunix首页 | 论坛 | 博客
  • 博客访问: 98206
  • 博文数量: 45
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 368
  • 用 户 组: 普通用户
  • 注册时间: 2014-01-21 16:28
文章分类

全部博文(45)

文章存档

2014年(45)

我的朋友

分类: LINUX

2014-01-22 15:15:56

 json 格式的例子:

"firstName": "John", "lastName": "Smith", "address": { 
"streetAddress": "21 2nd Street", "city": "New York", "state": "NY", "postalCode": 10021 }, 
"phoneNumbers": [ 
{ "type": "home", "number": "212 555-1234" }, { "type": "fax", "number": "646 555-4567" } ], 
"newSubscription": false, "companyName": null }

#将某test_url 的json格式转换成字典格式
def get(test_url):
        try:
                file=urllib2.urlopen(test_url,timeout=10).read()
                api_dict=json.loads(file)
        except urllib2.HTTPError,e:
                print e.code
        return api_dict

dict=get(test_url)
dict[type]


[zz] python 

json 

操作

 

2010-08-16 11:29 

json 

格式的例子:

 

"firstName": "John", 

"lastName": "Smith", 

"address": { 

"streetAddress": "21 2nd Street", 

"city": "New York", 

"state": "NY", 

"postalCode": 10021 

}, 

"phoneNumbers": [ 

{ "type": "home", "number": "212 555-1234" }, 

{ "type": "fax", "number": "646 555-4567" } 

], 

"newSubscription": false, 

"companyName": null 

}


[zz] python 

json 

操作

 

2010-08-16 11:29 

json 

格式的例子:

 

"firstName": "John", 

"lastName": "Smith", 

"address": { 

"streetAddress": "21 2nd Street", 

"city": "New York", 

"state": "NY", 

"postalCode": 10021 

}, 

"phoneNumbers": [ 

{ "type": "home", "number": "212 555-1234" }, 

{ "type": "fax", "number": "646 555-4567" } 

], 

"newSubscription": false, 

"companyName": null 

}


[zz] python 

json 

操作

 

2010-08-16 11:29 

json 

格式的例子:

 

"firstName": "John", 

"lastName": "Smith", 

"address": { 

"streetAddress": "21 2nd Street", 

"city": "New York", 

"state": "NY", 

"postalCode": 10021 

}, 

"phoneNumbers": [ 

{ "type": "home", "number": "212 555-1234" }, 

{ "type": "fax", "number": "646 555-4567" } 

], 

"newSubscription": false, 

"companyName": null 

}

阅读(236) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~