(4)编程将下面一个长字符串分割成相应的字典。 cookies = "anonymid=jy0ui55o-u6f6zd; depovince=GW; _r01_=1; JSESSIONID=abcMktGLRGjLtdhBk7OVw; ick_login=a9b557b8-8138-4e9d-8601-de7b2a633f80; _ga=GA1.2.1307141854.1562980962; _gid=GA1.2.201589596.1562980962; _c1=-100; first_login_flag=1; ln_uact=18323008898; ln_hurl=http://head.xiaonei.com/photos/0/0/men_main.gif; jebe_key=88f1340c-592c-4dd6-a738-128a76559f45%7Cad33b3c730fcdc8df220648f0893e840%7C1562981108370%7C1%7C1562981106763; jebe_key=88f1340c-592c-4dd6-a738-128a76559f45%7Cad33b3c730fcdc8df220648f0893e840%7C1562981108370%7C1%7C1562981106765; jebecookies=793eb32e-92c6-470d-b9d0-5f924c335d30|||||; _de=E77807CE44886E0134ABF27E72CFD74F; p=a00d65b1f779614cd242dc719e24c73e0; t=292ba8729a4151c1a357e176d8d91bff0; societyguester=292ba8729a4151c1a357e176d8d91bff0; id=969937120; xnsid=1700b2cc; ver=7.0; loginfrom=null; wp_fold=0"
时间: 2023-10-16 16:06:21 浏览: 151
可以使用以下代码将该字符串分割成字典:
```
cookies = "anonymid=jy0ui55o-u6f6zd; depovince=GW; _r01_=1; JSESSIONID=abcMktGLRGjLtdhBk7OVw; ick_login=a9b557b8-8138-4e9d-8601-de7b2a633f80; _ga=GA1.2.1307141854.1562980962; _gid=GA1.2.201589596.1562980962; _c1=-100; first_login_flag=1; ln_uact=18323008898; ln_hurl=http://head.xiaonei.com/photos/0/0/men_main.gif; jebe_key=88f1340c-592c-4dd6-a738-128a76559f45%7Cad33b3c730fcdc8df220648f0893e840%7C1562981108370%7C1%7C1562981106763; jebe_key=88f1340c-592c-4dd6-a738-128a76559f45%7Cad33b3c730fcdc8df220648f0893e840%7C1562981108370%7C1%7C1562981106765; jebecookies=793eb32e-92c6-470d-b9d0-5f924c335d30|||||; _de=E77807CE44886E0134ABF27E72CFD74F; p=a00d65b1f779614cd242dc719e24c73e0; t=292ba8729a4151c1a357e176d8d91bff0; societyguester=292ba8729a4151c1a357e176d8d91bff0; id=969937120; xnsid=1700b2cc; ver=7.0; loginfrom=null; wp_fold=0"
cookie_dict = {}
for cookie in cookies.split('; '):
key, value = cookie.split('=')
cookie_dict[key] = value
print(cookie_dict)
```
输出:
```
{'anonymid': 'jy0ui55o-u6f6zd', 'depovince': 'GW', '_r01_': '1', 'JSESSIONID': 'abcMktGLRGjLtdhBk7OVw', 'ick_login': 'a9b557b8-8138-4e9d-8601-de7b2a633f80', '_ga': 'GA1.2.1307141854.1562980962', '_gid': 'GA1.2.201589596.1562980962', '_c1': '-100', 'first_login_flag': '1', 'ln_uact': '18323008898', 'ln_hurl': 'http://head.xiaonei.com/photos/0/0/men_main.gif', 'jebe_key': '88f1340c-592c-4dd6-a738-128a76559f45%7Cad33b3c730fcdc8df220648f0893e840%7C1562981108370%7C1%7C1562981106765', 'jebecookies': '793eb32e-92c6-470d-b9d0-5f924c335d30|||||', '_de': 'E77807CE44886E0134ABF27E72CFD74F', 'p': 'a00d65b1f779614cd242dc719e24c73e0', 't': '292ba8729a4151c1a357e176d8d91bff0', 'societyguester': '292ba8729a4151c1a357e176d8d91bff0', 'id': '969937120', 'xnsid': '1700b2cc', 'ver': '7.0', 'loginfrom': 'null', 'wp_fold': '0'}
```
阅读全文