V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
sdlearn
V2EX  ›  Python

python 怎样删除 cookie 中的指定项

  •  
  •   sdlearn · 2014-04-02 15:05:52 +08:00 · 5525 次点击
    这是一个创建于 3670 天前的主题,其中的信息可能已经有所发展或是发生改变。
    比如下面这个cookie:
    <cookielib.CookieJar[ <Cookie OrigMUID=158D7FF11B506873av9A79E11A7268B0%2c3171e5f2v4cd4ebfb0b95285
    480cbd25 for .xxx.com/>, <Cookie SRCHUSR=AUTOREDIR=0&GEOVAR=&DOB=20140402 for .xxx.com/>, <Cookie _FS=NU=1 for .xxx.com/>, <Cookie _HOP= for .xxx.com/>]>
    我要删除里面的这一个:<Cookie OrigMUID=158D7FF11B506873av9A79E11A7268B0%2c3171e5f2v4cd4ebfb0b95285
    480cbd25 for .xxx.com/>该如何操作
    2 条回复    1970-01-01 08:00:00 +08:00
    cbsw
        1
    cbsw  
       2014-04-02 23:18:24 +08:00
    你是用的标准库么?遇到这样的问题可以先查文档再问么?看看这里 http://www.wapm.cn/smart-questions/smart-questions-zh.html
    sdlearn
        2
    sdlearn  
    OP
       2014-04-04 09:39:08 +08:00
    使用的是cookielib模块

    这样:
    cj = cookielib.CookieJar()
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
    urllib2.install_opener(opener)
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2849 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 06:14 · PVG 14:14 · LAX 23:14 · JFK 02:14
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.