Dictionary (JSON) data written to file with newlines, Python
import jsonif __name__ == '__main__':dict_data = {"one": 1, "two": 2, "three": 3}file = open('data.txt', 'a+') #Read and write, append to the file each time.not cover.json.dump(obj=dict_data, fp=file)file.write('\n')json.dump(obj=dict_data, fp=file)file.close()
Open the data.txt file to see:
{"one": 1, "two": 2, "three": 3}{"one": 1, "two": 2, "three": 3}