Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pickle
- custom_dict = {'key': 'value'}
- def save_file(data, file_name):
- with open(file_name + '.pickle', 'wb') as handle:
- pickle.dump(data, handle, protocol=pickle.HIGHEST_PROTOCOL)
- def read_file(file_name):
- with open(file_name + '.pickle', 'rb') as handle:
- return pickle.load(handle)
- save_file(custom_dict, 'custom_dict')
- new_custom_dict = read_file('custom_dict')
- print(new_custom_dict == custom_dict)
Add Comment
Please, Sign In to add comment