Python requests post请求如何直接发送字符串参数

使用 可以发送一个请求,参数是纯文本字符串。 参数

def post(url, data=None, json=None, **kwargs):
    r"""Sends a POST request.

    :param url: URL for the new :class:`Request` object.
    :param data: (optional) Dictionary, list of tuples, bytes, or file-like
        object to send in the body of the :class:`Request`.
    :param json: (optional) json data to send in the body of the :class:`Request`.
    :param \*\*kwargs: Optional arguments that ``request`` takes.
    :return: :class:`Response <Response>` object
    :rtype: requests.Response

    return request('post', url, data=data, json=json, **kwargs)



There are many times that you want to send data that is not form-encoded. If you pass in a string instead of a dict, that data will be posted directly.

所以很简单,直接使用 data=str 就行。

res =, data=url)