import pickle data = 1 pickle.dump(data, open('sample.pkl', 'wb')) data = pickle.load(open('sample.pkl', 'rb'))
with open('sample.pkl', 'wb') as f : pickle.dump(data, f)
with open('sample.pkl', 'rb') as f : data = pickle.load(f)