The-pickle of the Python module

Source: Internet
Author: User

The problem with Pickle is the same as for all other programming language-specific serialization problems, that is, it can only be used in Python, and may be incompatible with each other in Python, so it's okay to save only those unimportant data with pickle and not successfully deserialize it.

#----------------------------serialized Import Pickle dic={' name ': ' Alvin ', ' age ': at $, ' sex ': ' Male '} print (Type (DIC)) #< Class ' Dict ' > J=pickle.dumps (DIC) print (Type (j)) #<class ' bytes ' >  f=open (' serialized object _pickle ', ' WB ') # Note is that W is written STR,WB is written bytes,j is ' bytes ' F.write (j)  #-------------------equivalent to Pickle.dump (dic,f) f.close () #------------- ------------deserialization of Import Picklef=open (' serialized object _pickle ', ' RB ') Data=pickle.loads (F.read ()) #  equivalent to Data=pickle.load (f)  Print (data[' age ')  

  

The-pickle of the Python module

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.