I have a dictionary that looks like this
{'Berlin': {'Type1': 96},
'Frankfurt': {'Type1': 48},
'London': {'Type1': 288, 'Type2': 64, 'Type3': 426},
'Paris': {'Type1': 48, 'Type2': 96}}
I then want to write to a .txt file in the format
London
Type1: 288
Type2: 64
Type3: 426
Paris
Type1: 48
Type2: 96
Frankfurt
Type1: 48
Berlin
Type1: 98
I've tried to use
f = open("C:\\Users\\me\\Desktop\\capacity_report.txt", "w+")
f.write(json.dumps(mydict, indent=4, sort_keys=True))
but this prints like this:
{
"London": {
"Type1": 288,
"Type2": 64,
"Type3": 426
},
"Paris": {
"Type1": 48,
"Type2": 96
},
"Frankfurt": {
"Type1": 48
},
"Berlin": {
"Type1": 98
}
}
I'd like to have the punctuation and brackets removed. Is there a way to do this I can't see?