Python USES the requests module to send the implementation code for the GET and POST requests

  • 2020-05-12 02:47:30
  • OfStack

1) GET


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

import requests

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

Note: parameter datas is in json format

(2) POST


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

import requests

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

Note: parameter datas is in json format


Related articles: