User Tools

Site Tools


it:how-to_use_python_pickle

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

it:how-to_use_python_pickle [2018/12/01 19:40] (current)
pmay created
Line 1: Line 1:
 +====== How-To use Python Pickle ======
  
 +===== Pickle =====
 +<code python>
 +import pickle
 +
 +my_data = [1, 5, 7, 8]
 +
 +with open('​pickle_test.pkl',​ '​wb'​) as output_file:​
 +    pickle.dump(my_data,​ output_file)
 +</​code>​
 +
 +===== Un-Pickle =====
 +<code python>
 +import pickle
 +
 +with open('​pickle_test.pkl',​ '​rb'​) as input_file:
 +    my_read_data = pickle.load(input_file)
 +    ​
 +print(my_read_data)
 +</​code>​
it/how-to_use_python_pickle.txt · Last modified: 2018/12/01 19:40 by pmay