JSON:
[
{
"Ф.И.О.": "Иванов И.И.",
"data": {
"Год рождения": 1991,
"Город прописки": "Нур-Султан"
}
},
{
"Ф.И.О.": "Алтаев Н.А.",
"data": {
"Год рождения": 1991,
"Город прописки": "Шымкент"
}
},
{
"Ф.И.О.": "Иванов И.И.",
"data": {
"Год рождения": 1991,
"Город прописки": "Нур-Султан"
}
}
]
Python:
import json
with open('info.json', encoding='utf-8') as f:
templates = json.load(f)
print(templates)
for section, commands in templates.items():
print(section)
print('\n'.join(commands))
ВЫВОДИТ ОШИБКУ:
Traceback (most recent call last):
File "C:\Users\user\PycharmProjects\Practical work No.5\4.5.py", line 8, in <module>
for section, commands in templates.items():
AttributeError: 'list' object has no attribute 'items'
КАК ИСПРАВИТЬ???