简体   繁体   English

"请求中的数据和参数有什么区别?"

[英]what is the difference between data and params in requests?

I am using python requests module, I send my params like this before:我正在使用python requests模块,我之前发送我的参数是这样的:

requests.post(url=url, params=params)

but today, I find that I send my data like this, it fails, I change to this:但是今天,我发现我这样发送我的数据,它失败了,我改成这样:

requests.post(url=url, data=params)

then it is ok, what is the difference between data and params ?那么没关系, dataparams有什么区别?

I observed that the request got a header X-Requested-With:XMLHttpRequest , is it because of this?我观察到请求有一个标头X-Requested-With:XMLHttpRequest ,是因为这个吗?

According to the requests documentation<\/a> :根据请求文档<\/a>:

First of all, there are two different methods<\/strong> :首先,有两种不同的方法<\/strong>:

Params are sent in (appended to) the URI ( http://www.answer.com/here?param1=1&param2=2 ) while data is sent in the request body .参数在(附加到)URI ( http://www.answer.com/here?param1=1&param2=2 ) 中发送,而数据在请求正文中发送。 Usually sensitive data or that sent in large volumes is posted in the body because it's easier to secure and doesn't lead to huge URIs.通常敏感数据或大量发送的数据会发布在正文中,因为它更容易保护并且不会导致巨大的 URI。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM