小编rpd*_*123的帖子

如何在python中读取cookie

我是python cgi脚本的新手。我想在python中读取cookie。我尝试了以下代码:

from urllib2 import Request, build_opener, HTTPCookieProcessor, HTTPHandler
import cookielib

#Create a CookieJar object to hold the cookies
cj = cookielib.CookieJar()

#Create an opener to open pages using the http protocol and to process cookies.
opener = build_opener(HTTPCookieProcessor(cj), HTTPHandler())

#Check out the cookies
print "the cookies are: "
for cookie in cj:
    print cookie
Run Code Online (Sandbox Code Playgroud)

但是,我只看到the cookies are:味精。

难道我做错了什么?

python cookies cgi

4
推荐指数
1
解决办法
1万
查看次数

如何在python中为URL参数编码字符串

如何编码字符串,以便可以在url参数中传递编码的字符串?

python urlencode

0
推荐指数
1
解决办法
2897
查看次数

标签 统计

python ×2

cgi ×1

cookies ×1

urlencode ×1