save python dic 1

save python dic

import pickledict = {'Python' : '.py', 'C++' : '.cpp', 'Java' : '.java'}f = open("file.pkl","wb")pickle.dump(dict,f)f.close()

Here is what the above code is Doing:
1. We have created a dictionary named pickledict.
2. We have opened a file named file.pkl in write binary mode.
3. We have dumped the dictionary into the file.
4. We have closed the file.

Now, let’s see how to load the pickled file.

Similar Posts