requests之json系列(一)
以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://xxxx.com/api/xxx' 10 11 12 requests_body = { 13 "access_token":"xxxx", 14 "request_body":{ 15 "organizationName":"xxxx", 16 } 17 } 18 r =requests.post(url,json=requests_body) 19 data =r.content 20 data1 =json.loads(data) 21 locations = data1["data"] 22 listtemp =[] 23 for location in locations: 24 appImportance = location["appImportance"] 25 if appImportance =='3': 26 continue 27 appid = location["appId"] 28 listtemp.append(appid) 29 print(listtemp)