Skip to content

Commit

Permalink
chore: add time
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaaraly committed Jul 3, 2022
1 parent 517a8eb commit 0916340
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import datetime
import yaml


Expand Down Expand Up @@ -39,12 +40,15 @@ def __writeConfig(self):


def persist(data):
now = datetime.datetime.now()
fs_data = {'time': now, 'data': data}
print(now)
with open('./data.yaml', 'w', encoding='utf-8') as f:
yaml.dump(data, f, encoding='utf-8', allow_unicode=True)
yaml.dump(fs_data, f, encoding='utf-8', allow_unicode=True)


# Read data from data.yaml
def read_data():
with open('./data.yaml', encoding='utf-8') as f:
data = yaml.load(f, Loader=yaml.FullLoader)
return data
return data['data']

0 comments on commit 0916340

Please sign in to comment.