标签:dict class pre item collect 元组 end tps cookies
#!/usr/bin/env python # encoding: utf-8 import urllib.request from collections import defaultdict response=urllib.request.urlopen("https://twitter.com/login") headerstr=response.getheaders() d = defaultdict(list) for k, v in headerstr: if "set-cookie" in k: d[k].append(v) print(d.items())
上面只是为了做一个 列表 元组转字典的练习,下面才是开始
#!/usr/bin/env python # encoding: utf-8 import urllib.request from collections import defaultdict response=urllib.request.urlopen("https://twitter.com/login") headerstr=response.getheader("set-cookie") print(headerstr)
标签:dict class pre item collect 元组 end tps cookies
原文地址:https://www.cnblogs.com/c-x-a/p/9017885.html