In: Computer Science
I'm trying to use Jupyter (python) to convert the contents of a pkl file into a dictionary, WITHOUT using pandas.
I'm able to import pickle and can open my file...but I'm not sure how to create the dictionary.
CODE:
OUTPUT:
RAW CODE:
import pickle # importing module
dic = {1:"a",2:"b",3:"c",4:"d",5:"e",6:"f",7:"g",8:"h",9:"i"} # dictionary
out_file = open("file.pkl","wb") # opening file in writebinary mode
pickle.dump(dic,out_file) # writing dictionary into file
out_file.close() # closing file
# opening same file
pkl_file = open("file.pkl","rb") # opening file in readbinary mode
dic = pickle.load(pkl_file) # converting file to dictionary
print(dic) # printing dicionary
pkl_file.close() # closing file
NOTE:
If You have any doubts feel free to comment in comment
section.
DO VOTE(LIKE).