Cha*_*aco 9

SameSite2018 年 4 月 7 日在Pull Request #6413 中添加了对该属性的支持。

可以对旧版本进行猴子补丁以支持该属性:

try:
    from http.cookies import Morsel
except ImportError:
    from Cookie import Morsel

Morsel._reserved[str('samesite')] = str('SameSite')
Run Code Online (Sandbox Code Playgroud)

或使用六个

from six.moves.http_cookies import Morsel

Morsel._reserved[str('samesite')] = str('SameSite')
Run Code Online (Sandbox Code Playgroud)

  • 确保在打开 `unicode_literals` 模式时与 python 2 兼容。 (2认同)