python pickle & dill save data

Basic usage:

pickle / dill Python be used for most other data format stored objects; wherein pickle lambda functions not stored, the sequence of objects, etc., can be saved but dill. Which uses dill pickle and, like, when used, the use of

import pickle 

or

import dill as pickle

Basic Usage

  • save data
with open('dataset.pkl', 'wb') as f:
    data = {'0':1, '1':2}
    pickle.dump(data, f)
  • Loading data
with open('dataset.pkl', 'rb') as f:
    data = pickle.load(f)

Published 36 original articles · won praise 0 · views 20000 +

Guess you like

Origin blog.csdn.net/weixin_38102912/article/details/104149937