“Save Thing in pickle python” Réponses codées

Save Thing in pickle python

import pickle

a = {'hello': 'world'}

with open('filename.pickle', 'wb') as handle:
    pickle.dump(a, handle, protocol=pickle.HIGHEST_PROTOCOL)

with open('filename.pickle', 'rb') as handle:
    b = pickle.load(handle)

print a == b
TheProgrammer

Créer un fichier Pickle Python

import pickle
file_name='my_file.pkl'
f = open(file_name,'wb')
pickle.dump(my_data,f)
f.close()
Tremendous Enceladus

pickle.load python

import pickle
# load : get the data from file
data = pickle.load(open(file_path, "rb"))
# loads : get the data from var
data = pickle.load(var)
Doubtful Dingo

Enregistrer un fichier en cornichon

with open('mypickle.pickle', 'wb') as f:
    pickle.dump(some_obj, f)

# note that this will overwrite any existing file
# in the current working directory called 'mypickle.pickle'
Depressed Dogfish

Réponses similaires à “Save Thing in pickle python”

Questions similaires à “Save Thing in pickle python”

Plus de réponses similaires à “Save Thing in pickle python” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code