I have a python dictionary {'A': '1', 'B': '2', 'C': '3'}
. I want to write this dictionary into a file. This is how I did it;
test_dict = {'A': '1', 'B': '2', 'C': '3'}
f = open("dict.txt", "w")
f.write(str(test_dict))
f.close()
However, what I want the text file is to look like this;
{
'A': '1',
'B': '2',
'C': '3',
}
How do I add the newline when writing to the text file? I am using python 3.7