сохранение словарей в .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

+15 -2
View File
@@ -4,7 +4,12 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="aaf4cea1-996f-4616-a7e8-5aebcf6aea3e" name="Changes" comment="jsonForDumb.py" />
<list default="true" id="aaf4cea1-996f-4616-a7e8-5aebcf6aea3e" name="Changes" comment="jsonForDumb.py">
<change beforePath="$PROJECT_DIR$/.idea/dictionaries/project.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dictionaries/project.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/BotForTelegramm/jsonForDumb.py" beforeDir="false" afterPath="$PROJECT_DIR$/BotForTelegramm/jsonForDumb.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/BotForTelegramm/jsontest" beforeDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -213,7 +218,15 @@
<option name="project" value="LOCAL" />
<updated>1776345636447</updated>
</task>
<option name="localTasksCounter" value="17" />
<task id="LOCAL-00017" summary="jsonForDumb.py">
<option name="closed" value="true" />
<created>1776345903191</created>
<option name="number" value="00017" />
<option name="presentableId" value="LOCAL-00017" />
<option name="project" value="LOCAL" />
<updated>1776345903191</updated>
</task>
<option name="localTasksCounter" value="18" />
<servers />
</component>
<component name="UpdateCopyrightCheckinHandler">
+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.