1 #coding=utf-8 2 import requests 3 url = 'http://www.baidu.com' 4 f=open(r'cookies.txt','r') 5 cookies={} 6 for line in f.read().split(';'): 7 #其设置为1就会把字符串拆分成2份 8 name,value=line.strip().split('=',1) 9 cookies[name]=value 10 r = requests.get(url, cookies=cookies)