Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pickling python example

import pickle

def pickling(path, data):
    file = open(path,'wb')
    pickle.dump(data,file)

def unpickling(path):
    file = open(path, 'rb')
    b = pickle.load(file)
    return b

# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    dummy_data = ['item1', 'item2', 'item3']

    pickling('pickle_files/test.p', dummy_data)

    output = unpickling('pickle_files/test.p')

    print("Output=", output)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pickling #python
ADD COMMENT
Topic
Name
3+5 =