сохранение словарей в .json файл
This commit is contained in:
1 parent
2f34d53bdc
commit
f60e36a7fb
3 files changed
+27
-4
No files matched your search
@@ -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)
|
||||
Whitespace-only changes.
Reference in new issue
Block a user