Python development _ pickle

Source: Internet
Author: User

The data format used by the module is dedicated to python. Different versions are not backward compatible and cannot be recognized by other languages. To interact with other languages, you can use the built-in json package to use the pickle module. You can directly save Python objects to files without converting them into strings, you do not need to write the underlying file access operations into a binary file. The pickle module will create a binary format dedicated to the python language. Basically, you don't need to consider any file details. It will help you perform read and write exclusive operations in a clean manner, the only requirement is a valid file handle.
The two main functions in the module are dump () and load (). The dump () function accepts a file handle and a data object as parameters, and saves the data object to a specified file in a specific format. When we use the load () function to extract saved objects from a file,Know how to restore these objects to their original format.
The dumps () function executes the same serialization as the dump () function. Instead of accepting stream objects and saving serialized data to disk files, this function simply returns serialized data.
The loads () function executes the same deserialization as the load () function. Instead of accepting a stream object and reading serialized data from a file, it accepts the str object that contains the serialized data and directly returns the object.
CPickle is pickle to get a faster C language version.
Similar to cPickle, java serialization and deserialization operations

Source: http://www.bkjia.com/kf/201009/74973.html

The following is Example in the python API:

       collections    MemoRecord = namedtuple(,                                                                            (                                                                   super().         self.connection =                                 cursor =         type_tag, key_id =          type_tag ==                           cursor.execute(             key, task =                                                                           pickle.UnpicklingError(                        conn = sqlite3.connect(     cursor =     cursor.execute(     tasks =                                  task          cursor.execute(           cursor.execute(     memos = [MemoRecord(key, task)  key, task           file =       (            cursor.execute(            memos =      (      ==      main()

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.