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)
  • 相关阅读:
    Access restriction on class due to restriction on required library rt.jar?
    Why “no projects found to import”?
    MySQL
    您对无法重新创建的表进行了更改或者启用了“阻止保存要求重新创建表的更改”选项
    INTJINTJ——内向+直觉+思维+判
    豆瓣网案例分析报告
    如何使用Git
    如何在不到六个月的时间内成为一个开发者
    关于网站编程Alex
    string
  • 原文地址:https://www.cnblogs.com/bingabcd/p/7346389.html
Copyright © 2011-2022 走看看