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
import pickle
file_name='my_file.pkl'
f = open(file_name,'wb')
pickle.dump(my_data,f)
f.close()
import pickle
pickle.dump( favorite_color, open( "save.p", "wb" ) )
favorite_color = pickle.load( open( "save.p", "rb" ) )
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)
with open('filename', 'rb') as f:
x = pickle.load(f)
import pickle
example_dict = {1:"6",2:"2",3:"f"}
pickle_out = open("dict.pickle","wb")
pickle.dump(example_dict, pickle_out)
pickle_out.close()
import pickle
# dump : put the data of the object in a file
pickle.dump(obj, open(file_path, "wb"))
# dumps : return the object in bytes
data = pickle.dump(obj)