将cURL转换为pyCurl等效项

问题描述 投票:0回答:1

我有一个使用cURL的补丁请求,现在我想将它与python一起使用:

curl -X Patch -H "content-type: application/json" -d '{"activation": {"mode":"activate_immediate"},"transport_params":[{"destination_ip":"239.255.255.50","destination_port": 5004, "rtp_enabled": True, "source_ip": "192.168.10.115","source_port":"auto"}]}' http://ip:port/x-nmos/connection/v1.2/single/uuid/staged

任何人都可以用pyCurl等效项或我可以使用python做到这一点的任何其他方法来帮助我吗?

python json curl pycurl
1个回答
0
投票

我建议您使用@ C4tier提到的requestpyCurl lib。试试:

import requests
headers = {"content-type": "application/json"}
data = {"activation": {"mode":"activate_immediate"},"transport_params"[{"destination_ip":"239.255.255.50","destination_port": 5004, "rtp_enabled": True, "source_ip": "192.168.10.115","source_port":"auto"}]}
url = "http://ip:port/x-nmos/connection/v1.2/single/uuid/staged"
resquest = requests.patch(url = url, data = data, headers = headers)

由于IP或端口错误,我无法完成请求。确保请求正文正确!

© www.soinside.com 2019 - 2024. All rights reserved.