сохранение словарей в .json файл

This commit is contained in:
mega_krevetka committed 2026-04-16 17:42:22 +03:00
1 parent 2f34d53bdc
commit f60e36a7fb
3 files changed
+27 -4

No files matched your search

+12 -2
View File
@@ -1,4 +1,14 @@
import json
with open("jsontest", "w", encoding="utf-8") as f:
f.write(json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}]))
userLink = {135421234: "привет"}
wins = {123: "ping"}
looses = {83214623: "`'/"}
draws = {34554362: "запиточка ;"}
dif = {12326456432: "..."}
with open("jsontest.json", "w", encoding="utf-8") as f:
f.write(json.dumps([userLink, wins, looses, draws, dif], sort_keys=True, indent=4))
with open("jsontest.json", "r", encoding="utf-8") as f:
a = json.loads(f.read())
print(a)
View File
Whitespace-only changes.