添加README
This commit is contained in:
@@ -71,13 +71,13 @@ class User:
|
||||
self.course_process_dict[course_id]['lesson_processs'].append(([], lesson['lesson_id']))
|
||||
|
||||
|
||||
with open(self.save_path, 'w') as f:
|
||||
with open(self.save_path, 'w', encoding='utf-8') as f:
|
||||
json.dump(self.__json__(), f, indent=4)
|
||||
|
||||
def save_to_file(self):
|
||||
print(f"saved at {self.save_path}")
|
||||
self.get_course_progress()
|
||||
with open(self.save_path, 'w') as f:
|
||||
with open(self.save_path, 'w', encoding='utf-8') as f:
|
||||
json.dump(self.__json__(), f, indent=4)
|
||||
|
||||
def __json__(self):
|
||||
@@ -106,14 +106,14 @@ class User:
|
||||
|
||||
def load_user_from_json(user_id, user_data_dir = None)-> User:
|
||||
USER_DATA_DIR = user_data_dir if user_data_dir else LOCAL_USER_DATA_DIR
|
||||
with open(os.path.join(USER_DATA_DIR, f'{user_id}.json'), "r") as f:
|
||||
with open(os.path.join(USER_DATA_DIR, f'{user_id}.json'), "r", encoding='utf-8') as f:
|
||||
raw_json = f.read()
|
||||
user_data = json.loads(raw_json)
|
||||
return User(save_path = os.path.join(USER_DATA_DIR, f'{user_id}.json'), **user_data)
|
||||
|
||||
def create_user_json(user_id, user_data_dir = None):
|
||||
USER_DATA_DIR = user_data_dir if user_data_dir else LOCAL_USER_DATA_DIR
|
||||
with open(os.path.join(USER_DATA_DIR, f'{user_id}.json'), "w") as f:
|
||||
with open(os.path.join(USER_DATA_DIR, f'{user_id}.json'), "w", encoding='utf-8') as f:
|
||||
f.write(json.dumps({
|
||||
'user_id': user_id,
|
||||
'select_course': [],
|
||||
|
||||
Reference in New Issue
Block a user