mirror of
https://github.com/Justuser3310/ss14_chemistry_site.git
synced 2025-02-08 09:07:38 +00:00
Указание для файла
This commit is contained in:
parent
c5aa70fe5f
commit
744ce2666c
8
db.py
8
db.py
@ -9,12 +9,12 @@ if not os.path.exists('db.json'):
|
|||||||
print('Created new db.json')
|
print('Created new db.json')
|
||||||
|
|
||||||
|
|
||||||
def read_db():
|
def read_db(file = 'db.json'):
|
||||||
with open("db.json", "r", encoding="utf-8") as openfile:
|
with open(file, "r", encoding="utf-8") as openfile:
|
||||||
db = json.load(openfile)
|
db = json.load(openfile)
|
||||||
return db
|
return db
|
||||||
|
|
||||||
def write_db(db):
|
def write_db(db, file = 'db.json'):
|
||||||
js = json.dumps(db, indent=2, ensure_ascii=False)
|
js = json.dumps(db, indent=2, ensure_ascii=False)
|
||||||
with open("db.json", "w", encoding="utf-8") as outfile:
|
with open(file, "w", encoding="utf-8") as outfile:
|
||||||
outfile.write(js)
|
outfile.write(js)
|
||||||
|
Loading…
Reference in New Issue
Block a user