I have a very complex dictionary and dumping, loading directly using dill works. This is in reference to this answer. But there is a slight modification. I need to save this in some file and read that file for later use.
Here's a piece of my code:
NWORDSa
is the dictionary that i saved into 'abc.pkl'
pdict1 = dill.dumps(NWORDSa)
dill.dump_session('abc.pkl')
I do not know how to read it back to get the original NWORDSa
. I tried:
c = dill.load_session('abc.pkl')
NWORDS_b= dill.loads(c)
and (wanted to save it in a variable bbn)
with open('abc.pkl', 'rb') as f:
pickle.dump(bbn, f)
But both do not work. Is there a better method?
.pt
for pickle file extension (or at least that's what pycharm highlights which makes me assume that is the common extension). – Avelar