data (optional) Dictionary or list of tuples [(key, value)] (will
be form-encoded), bytes, or file-like object to send in the body of
the Request.
以及
files (optional) Dictionary of 'name': file-like-objects (or
{'name': file-tuple}) for multipart encoding upload. file-tuple can be
a 2-tuple ('filename', fileobj), 3-tuple ('filename', fileobj,
'content_type') or a 4-tuple ('filename', fileobj, 'content_type',
custom_headers), where 'content-type' is a string defining the content
type of the given file and custom_headers a dict-like object
containing additional headers to add for the file.
让我分享一下我的发现,尽管如果有人真正知道他/她在说什么的话,我会非常感激的。在
下面是requests api docs对request()方法的这些参数的说明:
以及
我猜在http请求中,}将被编码为}来查看。有关这些内容类型及其预期用途的更多信息,请参阅W3C recommendations。在
data
将被编码为内容类型application/x-www-form-urlencoded
,而{multipart/form-data
。如果同时传递数据和文件,后者也适用。这也可以通过查看结果request.headers
和{在requests QuickStart guide中给出了一些例子。这些可能也很好地说明了预期用途。在
相关问题 更多 >
编程相关推荐