如何在 python-requests 库中设置 POST 请求的内容类型? [英] How do I set the content-type for POST requests in python-requests library?

查看:32
本文介绍了如何在 python-requests 库中设置 POST 请求的内容类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用的一个 API 指定我需要一个特殊的内容类型字符串.我不知道如何在 python-requests 库中设置这个

One API I'm currently using specifies that I need a special content-type string. I don't know how do I set this in python-requests library

推荐答案

import requests

headers = {'Content-type': 'content_type_value'}
r = requests.get(url, headers=headers)

这篇关于如何在 python-requests 库中设置 POST 请求的内容类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆