python响应头部是什么

Python (175) 2023-05-23 09:06:52

1、响应头部可以为你提供有用的信息,例如响应有效负载的内容类型以及缓存响应的时间限制。 要查看这些头部,请访问 .headers:

>>>response.headers
{'Server':'GitHub.com','Date':'Mon,10Dec201817:49:54GMT','Content-Type':'application/json;charset=utf-8',...}

2、.headers 返回类似字典的对象,允许你使用键来获取头部中的值。 例如,要查看响应有效负载的内容类型,可以访问 Content-Type:

>>>response.headers['Content-Type']
'application/json;charset=utf-8'

以上就是python响应头部的介绍,希望对大家有所帮助。

本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。

THE END

发表回复