码迷,mamicode.com
首页 > 其他好文 > 详细

requests

时间:2017-12-25 13:35:04      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:color   encoding   org   nbsp   env   blog   相关   cat   default   

以post方式获取接口相关信息

 1 #! /usr/bin/env python
 2 # coding=utf-8
 3 import json
 4 import urllib
 5 import requests
 6 import sys
 7 reload(sys)
 8 sys.setdefaultencoding(utf-8)
 9 url = http://xxx/api/17676
10 requests_body = {
11     "access_token":"xxxx",
12     "request_body":{
13          "organizationName":"xx",
14           "appImportance":2,
15 }
16 }
17 r =requests.post(url,json=requests_body)
18 data =r.content
19 data1 =json.loads(data)
20 locations = data1["data"]
21 print(data)
22 for location in locations:
23     appid = location["appId"]
24     chineseName = location["chineseName"]
25     appImportance = location["appImportance"]
26     owner = location["owner"]
27     inter= str(appid)  + " " + str(chineseName) +" " + str(owner)  + " " + str(appImportance)
28     print(inter)

 

requests

标签:color   encoding   org   nbsp   env   blog   相关   cat   default   

原文地址:http://www.cnblogs.com/yspass/p/8108558.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!