因此,我找不到在线上真正可用于读取Cookie的Python 3脚本。 这是代码(解释之后的内容);
red_theme = "red_style.css"
blue_theme = "blue_style.css"
green_theme = "green_style.css"
dark_theme = "dark_style.css"
light_theme = "light_style.css"
### COOKIE WRITER + THEME SETTINGS
jar = Cookie.SimpleCookie()
if data.getvalue("t") == "red":
theme = red_theme
jar['s_theme']=red_theme
if data.getvalue("t") == "blue":
theme = blue_theme
jar['s_theme']=blue_theme
if data.getvalue("t") == "green":
theme = green_theme
jar['s_theme']=green_theme
if data.getvalue("t") == "dark":
theme = dark_theme
jar['s_theme']=dark_theme
if data.getvalue("t") == "light":
theme = light_theme
jar['s_theme']=light_theme
else:
theme = red_theme
jar['s_theme']=red_theme
### COOKIE READER
try:
jar = Cookie.SimpleCookie(os.environ["HTTP_COOKIE"])
theme = jar["s_theme"].value
except (Cookie.CookieError, KeyError):
theme = "error.css"
此脚本查找您是否具有?t = *****作为特定主题(红色,绿色,蓝色等)。然后,在该信息上,它以[s_theme = colour]的形式写一个cookie(罐子) 但是...读取的脚本无效。
### 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 + """\">
总结;尝试使主题设置器更改您选择的默认设置,因此,如果您转到https://...?theme=dark,则会将默认主题设置为黑暗。但是...我无法使用读取的脚本。
真的很感谢您的帮助-Reefive