设计一个程序,将temp的字符串值转化成一个有结构的字典 temp = ’smidV2=202109220129047b9a24c8900f8a224b45432544219767006de7f82cc536f20; user_trace_token=20210929004406-38524095-f6be-479b-8ee7-52c4fb6ede38; _ga=GA1.2.1953657374.1632847447; LGUID=20210929004407-43196c30-f591-4f24-aacb-dcfd69aa1ed2; gate_login_token=70519ffa95ee739658fde0c7583477727cd71120b9450a679ab0d2b9b91dfc97; LG_LOGIN_USER_ID=3a9a2ac62c84137f8e5a362c06b479e38ca48a56c1d8ad7eac7b032a67ca5e19; LG_HAS_LOGIN=1; showExpriedIndex=1; showExpriedCompanyHome=1; showExpriedMyPublish=1; hasDeliver=1; privacyPolicyPopup=false; index_location_city=%E5%B9%BF%E5%B7%9E; RECOMMEND_TIP=true; lg_stoken=1ad7e4df5d3cf8d29378410d83f9b9359d5d0aa8f286f823a14af2acf31eb5c654b91b9c6c56582563698fa7e70baba932aced7af9daca6dfbb71f4a876144e013ee1b3172c1; JSESSIONID=ABAAAECAAEBABII13D6B001DA5BE3F805DBDC5124937B71; WEBTJ-ID=20211008082929-17c5d4e0e679-0bcb6415631bcc-3a67410c-1327104-17c5d4e0e684e9; _putrc=AA6BE8EE420080C2123F89F2B170EADC; _gid=GA1.2.1275641970.1633652969; Hm_lvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1633068606,1633318199,1633533129,1633652969; PRE_UTM=; PRE_HOST=; PRE_LAND=https%3A%2F%2Fwww.lagou.com%2Fjobs%2F9542624.html; LGSID=20211008082928-ce4687ce-5e4b-4c1e-bb91-db396e6ae0e2; PRE_SITE=; login=true; unick=%E8%B5%B5%E6%80%9D%E6%9C%9D; sensorsdata2015session=%7B%7D; X_HTTP_TOKEN=964df8b0a92cd4f317925633613b7e0aacf0e0ed78; _SAFETY_CLOSE_TIME__21765909=1; Hm_lpvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1633652972; TG-TRACK-CODE=index_search; LGRID=20211008082937-8dd59b1b-7756-4b33-a16a-e080109e1bf1; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2221765909%22%2C%22first_id%22%3A%2217c096769d2a7-05dc7428ecc2f6-3a67410c-1327104-17c096769d3417%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24latest_referrer%22%3A%22%22%2C%22%24latest_utm_campaign%22%3A%22distribution%22%2C%22%24os%22%3A%22Windows%22%2C%22%24browser%22%3A%22Chrome%22%2C%22%24browser_version%22%3A%2292.0.4515.159%22%7D%2C%22%24device_id%22%3A%2217c096769d2a7-05dc7428ecc2f6-3a67410c-1327104-17c096769d3417%22%7D'
2条回答 默认 最新
- Fioman_Hammer 2021-10-29 14:04关注
temp = """ smidV2=202109220129047b9a24c8900f8a224b45432544219767006de7f82cc536f20; user_trace_token=20210929004406-38524095-f6be-479b-8ee7-52c4fb6ede38; _ga=GA1.2.1953657374.1632847447; LGUID=20210929004407-43196c30-f591-4f24-aacb-dcfd69aa1ed2; gate_login_token=70519ffa95ee739658fde0c7583477727cd71120b9450a679ab0d2b9b91dfc97; LG_LOGIN_USER_ID=3a9a2ac62c84137f8e5a362c06b479e38ca48a56c1d8ad7eac7b032a67ca5e19; LG_HAS_LOGIN=1; showExpriedIndex=1; showExpriedCompanyHome=1; showExpriedMyPublish=1; hasDeliver=1; privacyPolicyPopup=false; index_location_city=%E5%B9%BF%E5%B7%9E; RECOMMEND_TIP=true; lg_stoken=1ad7e4df5d3cf8d29378410d83f9b9359d5d0aa8f286f823a14af2acf31eb5c654b91b9c6c56582563698fa7e70baba932aced7af9daca6dfbb71f4a876144e013ee1b3172c1; JSESSIONID=ABAAAECAAEBABII13D6B001DA5BE3F805DBDC5124937B71; WEBTJ-ID=20211008082929-17c5d4e0e679-0bcb6415631bcc-3a67410c-1327104-17c5d4e0e684e9; _putrc=AA6BE8EE420080C2123F89F2B170EADC; _gid=GA1.2.1275641970.1633652969; Hm_lvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1633068606,1633318199,1633533129,1633652969; PRE_UTM=; PRE_HOST=; PRE_LAND=https%3A%2F%2Fwww.lagou.com%2Fjobs%2F9542624.html; LGSID=20211008082928-ce4687ce-5e4b-4c1e-bb91-db396e6ae0e2; PRE_SITE=; login=true; unick=%E8%B5%B5%E6%80%9D%E6%9C%9D; sensorsdata2015session=%7B%7D; X_HTTP_TOKEN=964df8b0a92cd4f317925633613b7e0aacf0e0ed78; _SAFETY_CLOSE_TIME__21765909=1; Hm_lpvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1633652972; TG-TRACK-CODE=index_search; LGRID=20211008082937-8dd59b1b-7756-4b33-a16a-e080109e1bf1; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2221765909%22%2C%22first_id%22%3A%2217c096769d2a7-05dc7428ecc2f6-3a67410c-1327104-17c096769d3417%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24latest_referrer%22%3A%22%22%2C%22%24latest_utm_campaign%22%3A%22distribution%22%2C%22%24os%22%3A%22Windows%22%2C%22%24browser%22%3A%22Chrome%22%2C%22%24browser_version%22%3A%2292.0.4515.159%22%7D%2C%22%24device_id%22%3A%2217c096769d2a7-05dc7428ecc2f6-3a67410c-1327104-17c096769d3417%22%7D """ # 先按照分号分割 data = temp.strip().split(";") resDict = {} for temp in data: # 将temp按照=分割 key,value = temp.strip().split("=") resDict[key] = value print(resDict)
结果:
如果觉得答案对你有帮助,请点击下采纳,谢谢~
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 找一个QT页面+目标识别(行人检测)的开源项目
- ¥15 有没有整苹果智能分拣线上图像数据
- ¥20 有没有人会这个东西的
- ¥15 cfx考虑调整“enforce system memory limit”参数的设置
- ¥30 航迹分离,航迹增强,误差分析
- ¥15 Chrome Manifest扩展引用Ajax-hook库拦截请求失败
- ¥15 用Ros中的Topic通讯方式控制小乌龟的速度,走矩形;编写订阅器代码
- ¥15 LLM accuracy检测
- ¥15 pycharm添加远程解释器报错
- ¥15 如何让子窗口鼠标滚动独立,不要传递消息给主窗口