Answers for "how to store a dictionary in a file python and keep the dict format"

2

how to save dict in txt format

dict = {'Python' : '.py', 'C++' : '.cpp', 'Java' : '.java'}
f = open("dict.txt","w")
f.write( str(dict) )
f.close()
Posted by: Guest on May-27-2020
2

python save dictionary to file

with open('saved_dictionary.pkl', 'wb') as f:
    pickle.dump(dictionary, f)
        
with open('saved_dictionary.pkl', 'rb') as f:
        loaded_dict = pickle.load(f)
Posted by: Guest on December-01-2021

Code answers related to "how to store a dictionary in a file python and keep the dict format"

Browse Popular Code Answers by Language