Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用响应对python进行卷曲_Python_Curl_Request - Fatal编程技术网

使用响应对python进行卷曲

使用响应对python进行卷曲,python,curl,request,Python,Curl,Request,我试图使用请求模块在python中复制下面的curl命令。curl命令如下: curl -X POST "https://api.appcenter.ms/v0.1/apps/{username}/{appname}/push/notifications" -H "accept: application/json" -H "X-API-Token: Token" -H "Content-Type: application/json" -d "{ \"notification_target

我试图使用
请求
模块在python中复制下面的
curl
命令。
curl
命令如下:

curl -X POST "https://api.appcenter.ms/v0.1/apps/{username}/{appname}/push/notifications" -H  "accept: application/json" -H  "X-API-Token: Token" -H  "Content-Type: application/json" -d "{  \"notification_target\": null,  \"notification_content\": {    \"name\": \"Nazwa\",    \"title\": \"Lampa\",    \"body\": \"Została wyłączona\"  }}"
我尝试了下面的代码,但返回代码400

import requests
h={'accept': 'application/json', 'X-API-Token':'TOKEN','Content-Type':'application/json'}
d={'\"notification_target\": null,  \"notification_content\": {    \"name\": \"Nazwa\",    \"title\": \"Lampa\",    \"body\": \"Została wyłączona\"'}
r = requests.post("https://api.appcenter.ms/v0.1/apps/{username}/{appname}/push/notifications", data=d, headers=h)

问题是python中的“null”,我必须不写任何东西,而且一切都正常:)

那么,到目前为止你完成了什么?有错误吗?向我们展示您的代码。将您的数据定义为dict并使用json关键字。