小编Rec*_*a20的帖子

放置请求在curl中工作,但不在Python中工作

我正在尝试使用curl制作一个'put'方法,一切工作正常,并且我得到了JSON:

curl -X PUT -d '[{"foo":"more_foo"}]' http://ip:6001/whatever?api_key=whatever
Run Code Online (Sandbox Code Playgroud)

但是由于某些原因,如下所示使用python requests模块:

import requests
url = 'http://ip:6001/whatever?api_key=whatever'

a = requests.put(url, data={"foo":"more_foo"})

print(a.text)
print(a.status_code)
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

500内部服务器错误

内部服务器错误

服务器遇到内部错误,无法完成您的请求。服务器超载或应用程序中有错误。

注意:服务器已启动并正在运行。

python http python-2.7 python-3.x python-requests

4
推荐指数
1
解决办法
771
查看次数

标签 统计

http ×1

python ×1

python-2.7 ×1

python-3.x ×1

python-requests ×1