import requests try: import cookielib except: import http.cookiejar as cookielib session = requests.session() session.cookies = cookielib.LWPCookieJar(filename="cookies.txt") #服务器返回的 cookie 可以保存到本地 response_text = session.post(post_url, data=post_data, headers=header) session.cookies.save() ----------------------------------------- try: session.cookies.load(ignore_discard=True) except: print ("cookie未能加载")