①GET
# -*- coding:utf-8 -*-
import requests
def get(url, datas=None, **kwargs):
response = requests.get(url, params=datas, **kwargs)
json = response.json()
return json
实例
if __name__ == '__main__':
url = 'http://127.0.0.1:8080/test'
datas = {
'aaa' : 'bbb'
}
headers = {
'Authorization' : 'xxxxxx'
}
ret = http_client.get(url, datas, headers=headers)
print ret
# -*- coding:utf-8 -*-
import requests
def post(url, datas=None):
response = requests.post(url, data=datas)
json = response.json()
return json
注:参数datas为json格式