Guest User

Untitled

a guest
Sep 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. import pickle
  2.  
  3. custom_dict = {'key': 'value'}
  4.  
  5. def save_file(data, file_name):
  6. with open(file_name + '.pickle', 'wb') as handle:
  7. pickle.dump(data, handle, protocol=pickle.HIGHEST_PROTOCOL)
  8.  
  9. def read_file(file_name):
  10. with open(file_name + '.pickle', 'rb') as handle:
  11. return pickle.load(handle)
  12.  
  13. save_file(custom_dict, 'custom_dict')
  14.  
  15. new_custom_dict = read_file('custom_dict')
  16.  
  17. print(new_custom_dict == custom_dict)
Add Comment
Please, Sign In to add comment