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

Original 2017-01-09 17:31:42 368
abstract:①GET# -*- coding:utf-8 -*-  import requests  def get(url, datas=None):   response = requests.get(url, params=datas)   json&nb

①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请求的实现代码请关注PHP中文网(www.php.cn)其他文章!

Release Notes

Popular Entries