zhiqingstudy

Be a young person with knowledge and content

Why serialize?
How can the dictionary, list, collection and various objects in memory be saved in a file?

How to save instances of self defined classes in a file?

How to read data from files and let them restore to their own instances of corresponding classes in memory?

A set of protocols should be designed to save the data in memory to a file according to certain rules. File is a byte sequence, so data must be converted into byte sequence and output to file, which is called serialization. Conversely, the type restored from the byte sequence of a file to memory is deserialization.

definition
Serialization

Store objects in memory and turn them into bytes. -> Binary

Deserialization

将文件中的一个个字节恢复成内存中对象。<-二进制

Serializing and saving to a file is persistence.

The data can be serialized and persisted, or transmitted over the network; You can also deserialize the byte sequence received in the file or on the network.

Python provides a pickle library.

Pickle Library

Serialization and deserialization modules in Python

Serialized application
Generally speaking, local serialization is rarely used, and most application scenarios are in network transmission.

After the data is serialized, it is transmitted to the remote node through the network. The service on the remote server can deserialize the received data.

However, it should be noted that the remote receiver must have the corresponding data type when reversing the sequence, or an error will be reported. In particular, user-defined classes must have consistent definitions remotely.

comment
head sculpture
Code:
Related

Why you shouldn't stay at a job for more than 2 years?

3 harsh facts long-distance relationships

how to keep your girlfriend interested in a long-distance relationship




Unless otherwise specified, all content on this website is original. If the reprinted content infringes on your rights, please contact the administrator to delete it
Contact Email:2380712278@qq.com

Filing number:皖ICP备19012824号