From Dictionary To File Python
Posted
by
user3600560
on Stack Overflow
See other posts from Stack Overflow
or by user3600560
Published on 2014-08-24T16:08:32Z
Indexed on
2014/08/24
16:20 UTC
Read the original article
Hit count: 159
python
I am basically trying to write this information from my dictionary to this file. I have this dictionary named files = {} and it is for a filing system I am making. Anyhow it is always being update with new items, and I want those items to be uploaded to the file. Then if you exit the program the files are loaded back to the dictionary files = {}. Here is the code I have so far:
file = {}
for i in files:
g = open(i, 'r')
g.read(i)
g.close()
EDIT
I want the contents of the dictionary to be written to a file. The items inside the dictionary are all stored like this:
files[filename] = {filedate:filetext}
where filename is the file's name, filedate is the date that the file was made on, and the filetext is the files contents.
© Stack Overflow or respective owner