/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/python/py-502-31-014/main.py
21 строка
518 B
Spirzen
Code migration pack
09 июн 2026, 01:41
09 июн 2026, 01:41
cebc284
Код
Авторство
О чём код?
import json data = { "users": [ {"id": 1, "name": "Alice", "active": True}, {"id": 2, "name": "Bob", "active": False} ], "total": 2 } # Сериализация в строку json_str = json.dumps(data, indent=2) print(json_str) # Сохранение в файл with open('data.json', 'w', encoding='utf-8') as f: json.dump(data, f, ensure_ascii=False, indent=2) # Чтение из файла with open('data.json', 'r', encoding='utf-8') as f: loaded_data = json.load(f)