如何在保留所有信息的字符串中转换 'cookie'?

how can I transform a 'cookie' in a string keeping all the info?

我想将一些cookies转换成字符串,以便重新使用。问题是 cookie 中充满了引号和符号,当我尝试将其转换为字符串时,我丢失了很多信息

这是一个有:

response.cookies

当我尝试将其转换为字符串时,结果如下:

str(response.cookies)

', , , , , , , , , , =]=9

因此,如您所见,我丢失了很多信息,我如何将 cookie 转换为保留所有信息的字符串?

提前致谢

关于requests.cookies.RequestsCookieJar有一个get_dict方法

d = response.cookies.get_dict()

Source code

def get_dict(self, domain=None, path=None):
    """Takes as an argument an optional domain and path and returns a plain
    old Python dict of name-value pairs of cookies that meet the
    requirements.

    :rtype: dict
    """
    dictionary = {}
    for cookie in iter(self):
        if (domain is None or cookie.domain == domain) and (
            path is None or cookie.path == path
        ):
            dictionary[cookie.name] = cookie.value
    return dictionary