• 浏览器的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'}
    >>> 
    
  • 相关阅读:
    Block深入浅出
    JSPatch 遇上swift
    iPhone左下角app图标
    Handoff使用指南
    实习任务——导出excel
    实习任务——对查询结果进行筛选过滤
    Markdown基本语法
    学习笔记(二)——类加载及执行顺序
    #学习笔记(一)——static
    写给过去的3年,拥抱2016
  • 原文地址:https://www.cnblogs.com/c-aha/p/10120857.html
Copyright © 2020-2023  润新知