I want to save my dictionary to a file in a way that it can be easily imported afterwards keeping its dictionary meaning. If I do the following:
def save_dict_to_file(dic):
f = open('dict.txt','w')
f.write(str(dic))
f.close()
And then, if I want to load the dict from the file, by doing this:
d={}
fi=open("dict.txt","r")
lineinfile=fi.readlines()
d=lineinfile
print(type(d))
The result I obtain is a list, not a dictionary. Without using any module, how can this be solved? Was my error when exporting the dictionary or when importing it?