python 复制文本形成字典
def headx(aab): ab=[] ax1=aab.split('\n') for i in ax1: ax2=i.split('\t') ab.append((ax2[0],ax2[1])) tt=dict(ab) return tt head1=headx(aab) print(head1) aaba='''User-Agent Dalvik/2.1.0 (Linux; U; Android 6.0.1; SM-A9100 Build/MMB29M) Host acs.m.taobao.com Accept-Encoding gzip Connection close''' head2=headx(aaba) print(head2)
{'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 6.0.1; SM-A9100 Build/MMB29M)', 'Host': 'acs.m.taobao.com', 'Accept-Encoding': 'gzip', 'Connection': 'close'}