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
  • 相关阅读:
    springboot2 pagehelper 使用笔记
    springboot2 config_toolkit 并且设置全局获取数据GlobalUtil
    springboot2 redis
    Python问题汇总
    MAC安装Win10系统安装相关问题
    DEDE开发网站总部
    DEDE 调用文章中略缩图的原图
    塑形动作
    dede初学
    打印机维护经验
  • 原文地址:https://www.cnblogs.com/catherine007/p/8590230.html
Copyright © 2011-2022 走看看