import pickle
lists = [1, 2, 3, 4, 5]
f = open('tmp_pickle.pic', 'wb')
pickle.dump(lists, f)
f.close()
f = open('tmp_pickle.pic', 'rb')
unpickledlist = pickle.load(f)
print(unpickledlist)
Python pickle syntax