Python learning diary (xviii) serialization module

What is the sequence?

That every element is arranged in an orderly

What is serialized?

Is the original lists, dictionaries and other content into a string of process

When will use serialization?

Storing data (the data in a file, database), network transmission, etc.

The purpose of serialization

1. custom object so some form of persistent storage

2. The object is passed from one place to another

3. To make the program more maintainable

 

Serialization: data structures into a string

Deserialize: string into a data structure

 

Three series of modules:

1.Json

Features:

json is a universal serial format data and only a small part (str, list, dict, tuple, digital) can be converted to a string type by json

 

2.Pickle

Features:

pickle data types of all of python may be converted into a string, the sequence of the pickle python only able to understand the content, and the partial sequence of the code dependent python

 

3.Shelve

Features:

shelve can serialize the handle, the handle can be used directly is very convenient to operate

 

Guess you like

Origin www.cnblogs.com/Fantac/p/11441326.html