zoukankan      html  css  js  c++  java
  • requests模块参数介绍

    调用关系

    requests.get()
    requests.post()
    requests.put()
    
    requests.request('post')
    

    get请求

    requests.get(
    	url='xxx',
    	params={'k1':'v1','nid':888}   #get传参,在url上进行传参的
    	cookies={},
    	headers={},
    )
    # http://www.baidu.com?k1=v2andnid=888
    # get 请求没有请求体,不能发data
    

    post请求

    requests.post(
    	url='xxx',
    	params={'k1':'v1','nid':888}   #在url上进行传参的
    	cookies={},
    	headers={},
    	data={},
    	json={},  #内部序列化
    )
    
    #注意:请求头
    # 1,一般向后台提交数据的时候用post
    # 2,默认请求头 application/x-www-form-urlencoded,request.post取值
    
    ##如果带application/x-www-form-urlencoded。。数据库就是form data
    
    #如果带request。。。数据库就是
    #requests.post(url='',data={''},headers={'content-type':'application/json'})
    
    requests.post(url='',json={''})
    #自动携带 {'content-type':'application/json'}
    
    requests.post(url='',data={''})
    #自动携带application/x-www-form-urlencoded
    

      其他请求

    requests.get(url, params=None, **kwargs)
    requests.post(url, data=None, json=None, **kwargs)
    requests.put(url, data=None, **kwargs)
    requests.head(url, **kwargs)
    requests.delete(url, **kwargs)
    requests.patch(url, data=None, **kwargs)
    requests.options(url, **kwargs)
      
    # 以上方法均是在此方法的基础上构建
    requests.request(method, url, **kwargs)
    

     

    ###重定向

    allow_redirects=True
  • 相关阅读:
    android权限大全
    Java反射经典实例
    SD卡的寄存器 SD总线协议 CRC算法
    ARM CortexM3 操作模式和特权级别
    使用 Printf via SWO/SWV 输出调试信息
    embOS实时操作系统 概览
    embOS实时操作系统 多任务调度
    android wifi hotspot
    Eclipse Java 智能提示
    ARM CortexM3 概览
  • 原文地址:https://www.cnblogs.com/catherine007/p/8590230.html
Copyright © 2011-2022 走看看