首页 > 编程 > Python > 正文

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

2019-11-25 16:32:37
字体:
来源:转载
供稿:网友

①GET

# -*- coding:utf-8 -*-import requestsdef get(url, datas=None):  response = requests.get(url, params=datas)  json = response.json()  return json

注:参数datas为json格式

②POST

# -*- coding:utf-8 -*-import requestsdef post(url, datas=None):  response = requests.post(url, data=datas)  json = response.json()  return json

注:参数datas为json格式

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表