Let's say I have a dictionary and I want to write it into an existing file. How can I do so without losing anything that could potentially already exist in the file? What I was thinking of is doing the following:
def write_report(r, filename):
input_filename=open(filename, "a")
input_filename.close()
for (k,v) in r.items():
input_filename.write(k,v)
return filename
what I want to make sure is that the filename correctly contains the dictionary.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…