I have a dict:
dictionary1 = {100: {num: 1, age: 2, line: 3}}
dictionary2 = {90: {num: 1, age: 50, line: 4}}
I need to write this data into file line by line in the following format:
# HEADER 100 #
1 1 2 3
# HEADER 90 #
1 1 50 4
How to do that using Python?
CodePudding user response:
for i in dictionary1:
print('HEADER ',i)
print('1 ' ' '.join([str(x) for x in list(dictionary1[i].values())]))
You can change dictionary1 to dictionary2 for other values.