zoukankan      html  css  js  c++  java
  • requests.post发送字典套字典

    import requests
    import json
    a = {
            "data": {
                "project": {
                    "url": "https: //www.teambition.com/project/596823f91f2d170ed3287f29/home",
                    "_organizationId": "59682393361ddc461fa0f252",
                    "_id": "596823f91f2d170ed3287f29",
                    "name": "Issue管理"
                },
                "task": {
                    "content": "FSA10001测试",
                    "executor": {
                        "_id": "596829cfe525d47670c4e479",
                        "name": "冯超群",
                        "avatarUrl": "https: //striker.teambition.net/thumbnail/110ud2216b9615c796999e437606a63f8033/w/200/h/200"
                    },
                    "_id": "5971cf438900c23e17cd3fcb"
                },
                "user": {
                    "_id": "59682392e525d47670c4d49a",
                    "name": "高飞",
                    "avatarUrl": "https: //striker.teambition.net/thumbnail/110u54004f5d5582fc2e6eb7a08541f1573a/w/200/h/200"
                }
            },
            "event": "task.remove"
        }
    #方式一
    # headers = {"Content-Type":"application/json"}
    # requests.post(url='http://127.0.0.1:8000/api/index.html',headers=headers,data=json.dumps(a))
    #方式二
    # requests.post(url='http://127.0.0.1:8000/api/index.html',json=a) #只有body里面有
    
    #下面的请不要看------------------------------------------------------------------------------------------------
    #经典错误方式
    # headers = {"Content-Type":"application/x-www-form-urlencoded"}
    # requests.post(url='http://127.0.0.1:8000/api/index.html',headers = headers,data=a) #post和body里面都只有字典的key
    #SB错误方式一
    # headers = {"Content-Type":"application/x-www-form-urlencoded"}
    # requests.post(url='http://127.0.0.1:8000/api/index.html',headers = headers,json=a)
    #SB错误方式二
    # headers = {"Content-Type":"application/x-www-form-urlencoded,application/json"}
    # requests.post(url='http://127.0.0.1:8000/api/index.html',headers = headers,data=a)
    

      

  • 相关阅读:
    Python Scrapy环境配置教程+使用Scrapy爬取李毅吧内容
    Python 基础语法+简单地爬取百度贴吧内容
    Hadoop Mapreduce 工作机制
    Myeclipse 配置Git详解
    Java 多线程详解
    Hadoop Mapreduce 案例 wordcount+统计手机流量使用情况
    Hadoop HDFS NameNode工作机制
    Hadoop HDFS元数据目录分析
    Hadoop HDFS DataNode 目录结构
    Hadoop HDFS 文件块大小
  • 原文地址:https://www.cnblogs.com/wuyongqiang/p/7308591.html
Copyright © 2011-2022 走看看