浏览器的cookie的值改成字典格式

首先我们把复制的cookie的值赋给b

>>> cookies = 'bid=Qzw9cKnyESM; ll="108288"; __yadk_uid=4YChvgeANLBEh4iV00n1tc0HQ8zpmSl1; __utmc=30149280; __utmc=223695111; _vwo_uuid_v2=D8099FF3ECFE384A3F35BFA190C05A5EE|91f795432cda34bbc17ba6265fb33177; ps=y; dbcl2="169126613:FUpqH/CNWB8"; ck=pyZ7; ap=1; push_noty_num=0; push_doumail_num=0; __utmz=30149280.1520490941.8.7.utmcsr=accounts.douban.com|utmccn=(referral)|utmcmd=referral|utmcct=/login; __utmv=30149280.16912; __utmz=223695111.1520492304.6.4.utmcsr=douban.com|utmccn=(referral)|utmcmd=referral|utmcct=/search; ct=y; __utma=30149280.1712477244.1514880643.1520490941.1520496097.9; __utmb=30149280.0.10.1520496097; __utma=223695111.1169484511.1516955420.1520492304.1520496097.7; __utmb=223695111.0.10.1520496097; _pk_ref.100001.4cf6=%5B%22%22%2C%22%22%2C1520496097%2C%22https%3A%2F%2Fwww.douban.com%2Fsearch%3Fsource%3Dsuggest%26q%3D%25E5%2589%258D%25E4%25BB%25BB%22%5D; _pk_ses.100001.4cf6=*; _pk_id.100001.4cf6=21a4461bbb469631.1516955420.7.1520496674.1520492685'

然后根据分号切片

>>>line = cookies.split(';')

然后遍历并切片存入字典cookie

>>> cookie={}
>>> for i in line:
key,value = i.split('=',1)
cookie[key] = value

然后打印一下看下效果

>>> print(cookie)
{'bid': 'Qzw9cKnyESM', ' ll': '"108288"', ' __yadk_uid': '4YChvgeANLBEh4iV00n1tc0HQ8zpmSl1', ' __utmc': '223695111', ' _vwo_uuid_v2': 'D8099FF3ECFE384A3F35BFA190C05A5EE|91f795432cda34bbc17ba6265fb33177', ' ps': 'y', ' dbcl2': '"169126613:FUpqH/CNWB8"', ' ck': 'pyZ7', ' ap': '1', ' push_noty_num': '0', ' push_doumail_num': '0', ' __utmz': '223695111.1520492304.6.4.utmcsr=douban.com|utmccn=(referral)|utmcmd=referral|utmcct=/search', ' __utmv': '30149280.16912', ' ct': 'y', ' __utma': '223695111.1169484511.1516955420.1520492304.1520496097.7', ' __utmb': '223695111.0.10.1520496097', ' _pk_ref.100001.4cf6': '%5B%22%22%2C%22%22%2C1520496097%2C%22https%3A%2F%2Fwww.douban.com%2Fsearch%3Fsource%3Dsuggest%26q%3D%25E5%2589%258D%25E4%25BB%25BB%22%5D', ' _pk_ses.100001.4cf6': '*', ' _pk_id.100001.4cf6': '21a4461bbb469631.1516955420.7.1520496674.1520492685'}
>>>
上一篇:IOS UIColor 自定义颜色


下一篇:centos7 minimal版本下mysql的安装