推荐学习书目
› 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 · Apr 2, 2014 · 6275 views
    This topic created in 4584 days ago, the information mentioned may be changed or developed.
    比如下面这个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 replies  •  1970-01-01 08:00:00 +08:00
    cbsw
        1
    cbsw  
       Apr 2, 2014
    你是用的标准库么?遇到这样的问题可以先查文档再问么?看看这里 http://www.wapm.cn/smart-questions/smart-questions-zh.html
    sdlearn
        2
    sdlearn  
    OP
       Apr 4, 2014
    使用的是cookielib模块

    这样:
    cj = cookielib.CookieJar()
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
    urllib2.install_opener(opener)
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3049 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 14:26 · PVG 22:26 · LAX 07:26 · JFK 10:26
    ♥ Do have faith in what you're doing.