Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我的cookie阅读器坏了_Python_Python 3.x_Cookies - Fatal编程技术网

Python 我的cookie阅读器坏了

Python 我的cookie阅读器坏了,python,python-3.x,cookies,Python,Python 3.x,Cookies,因此,我在网上找不到任何Python3脚本可以用来读取cookies。 下面是代码(解释后面是什么) 此脚本将查找是否将?t=****作为特定主题(红色、绿色、蓝色等)。然后在该信息上写一个cookie(jar)作为[s_theme=color] 但是阅读脚本不起作用 ### COOKIE READER try: jar = Cookie.SimpleCookie(os.environ["HTTP_COOKIE"]) theme = jar["s_theme"].value ex

因此,我在网上找不到任何Python3脚本可以用来读取cookies。 下面是代码(解释后面是什么)

此脚本将查找是否将?t=****作为特定主题(红色、绿色、蓝色等)。然后在该信息上写一个cookie(jar)作为[s_theme=color] 但是阅读脚本不起作用

### COOKIE READER
try:
    jar = Cookie.SimpleCookie(os.environ["HTTP_COOKIE"])
    theme = jar["s_theme"].value
except (Cookie.CookieError, KeyError):
    theme = "error.css"
在HTML代码之后;它是这样做的:

<link rel="stylesheet" href=\"""" + theme + """\">

总之,;尝试创建一个主题设置器,该设置器根据您选择的默认主题进行更改,因此如果您转到,它会将您的默认主题设置为暗。但是我不能读剧本


非常感谢您的帮助-Reefive

那是什么
Cookie.SimpleCookie
?Python3中没有
Cookie
模块。有
http.cookies
,但您显然没有使用它。那么你在用什么呢?哦,是的,忘了提到,在我的代码OK的顶部有
导入Cookies,os
,但是
导入Cookies
会因为
导入错误而失败,因为没有这样的模块。所以,要么你不是真的在运行Python3,要么你安装了一些第三方库,你没有告诉我们!我的意思是
导入Cookie
但是在Python3中仍然没有这个名称。所以,再说一遍,要么你不是真的在运行Python3,要么你在使用我在PyPI上找不到的第三方库,所以你必须告诉我们它是什么。
<link rel="stylesheet" href=\"""" + theme + """\">