Hi I have to write a function that takes as arguments dictionaries and file name and saves it into a file with each dictionary in new line:
For example this is the list of dictionaries:
[[{'a': 1, 'b': 2}, {'aa': 2, 'bb': 3}]
This is my code:
def write_list_of_ngram_dicts(list_of_dicts, filename):
import json
open(filename, 'w', encoding='utf-8')
for dic in list_of_dicts:
json.dump(dic, filename)
filename.write("\n")
But sadly it doesn't work and I don't understand why?, maybe there is another way to do it?
thank you:)