python为什么不适用pickle来直接序列化requests.的session.cookies?
PHP中文网
PHP中文网 2017-04-18 10:19:55
0
2
684
import requests
sess=requests.session()
resp=sess.get('http://www.so.com')
f=open('cookiefile','wb')
pickle.dump(resp.cookies,f)  #为什么很多代码都不是这样,而是使用cookielib的LWPCookieJar?
f.close()
PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
大家讲道理
  1. How do you restore it, use load ?

  2. After restoration, how do you operate cookies (add, delete, modify, check)

  3. The cookie after you load is just a string. There are no more abstract operations, and you have to write your own functions to implement it

  4. Cookie is an entity, so it is naturally suitable to use class to abstractly encapsulate it

  5. It’s not that you can’t use pickle, it’s a question of convenience or inconvenience

  6. It is a compromise choice after weighing the pros and cons of all aspects

小葫芦

First of all, pickle is not safe and it is unique to Python. If you interact with other languages, it cannot be operated

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!