add multi-language support for file read

This commit is contained in:
Jack Lee
2023-06-14 16:54:46 +08:00
committed by GitHub
parent 60dbe0ac1c
commit acc0feec12

6
db.py
View File

@@ -10,11 +10,11 @@ class DB:
os.makedirs(self.path, exist_ok=True)
def __getitem__(self, key):
with open(self.path / key) as f:
with open(self.path / key, encoding='utf-8') as f:
return f.read()
def __setitem__(self, key, val):
with open(self.path / key, 'w') as f:
with open(self.path / key, 'w', encoding='utf-8') as f:
f.write(val)
@@ -25,4 +25,4 @@ class DBs:
logs: DB
identity: DB
input: DB
workspace: DB
workspace: DB