python

超轻量级php框架startmvc

Python 使用requests模块发送GET和POST请求的实现代码

更新时间:2020-04-24 03:15:01 作者:startmvc
①GET#-*-coding:utf-8-*-importrequestsdefget(url,datas=None):response=requests.get(url,params=datas)json=response.json(

①GET


# -*- coding:utf-8 -*-

import requests

def get(url, datas=None):
 response = requests.get(url, params=datas)
 json = response.json()
 return json

注:参数datas为json格式

②POST


# -*- coding:utf-8 -*-

import requests

def post(url, datas=None):
 response = requests.post(url, data=datas)
 json = response.json()
 return json

注:参数datas为json格式

Python requests GET POST