I want to write a dictionary into a file. The code is:
fs = open( store_file , "w" )
for k in store_dic:
temp_line = k + " " + store_dic[k] + "\n"
fs.write( temp_line )
logger.info( "store_record " + store_file + " " + temp_line[:-1] )
fs.close
As you see, I traverse the dictionary of store_dic and write in the file at the same time.
Because I will call this code every 6 seconds, are there any ways to improve this?
Thank you.
Just use json module.