如何在python中执行带参数的curl命令
本文最后更新于:2024年2月16日星期五下午3点57分
以 Github Api 为例:
curl -I
curl命令为:
curl -I https://api.github.com/repos/FoldCle/FoldCle.com/issues/1/comments对应python代码为:
your_url="https://api.github.com/repos/FoldCle/FoldCle.com/issues/1/comments"
res=requests.get(url=your_url).headers
print(res)curl -d
curl命令为:
curl \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token <TOKEN>" \
https://api.github.com/repos/OWNER/REPO/issues/comments/COMMENT_ID \
-d '{"body":"Me too"}'对应Python代码为:
data={"body":"Me too"}
repository='OWNER/REPO'
comment_id='COMMENT_ID'
token='TOKEN'
requests.patch(data=json.dumps(data),
url="https://api.github.com/repos/{}/issues/comments/{}".format(repository,comment_id),
headers={'Authorization': 'token {}'.format(token)})未完待续
如何在python中执行带参数的curl命令
https://asyu.in/gongju/curl_in_python/