>>> import pickle
>>> l = [1,2,3,4]
>>> with open("test", "wb") as fp: #Pickling
... pickle.dump(l, fp)
...
>>> with open("test", "rb") as fp: # Unpickling
... b = pickle.load(fp)
...
>>> b
[1, 2, 3, 4]
>>> import json
>>> with open("test", "w") as fp:
... json.dump(l, fp)
...
>>> with open("test", "r") as fp:
... b = json.load(fp)
...
>>> b
[1, 2, 3, 4]