From fc9f5f13698e9e10736e77f1da151f79f5b552b8 Mon Sep 17 00:00:00 2001 From: LibraHp_0928 <1941163264@qq.com> Date: Tue, 13 Feb 2024 14:24:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- util/ConfigUtil.py | 16 +++++++++++++--- util/LoginUtil.py | 5 +++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/util/ConfigUtil.py b/util/ConfigUtil.py index aca9745..4674bab 100644 --- a/util/ConfigUtil.py +++ b/util/ConfigUtil.py @@ -16,14 +16,24 @@ def save_user(cookies): def read_files_in_folder(): # 获取文件夹下的所有文件 files = os.listdir(user_path) - + # 如果文件夹为空 + if not files: + return None # 输出文件列表 - print("已保存用户:") + print("已登录用户列表:") for i, file in enumerate(files): print(f"{i + 1}. {file}") # 选择文件 - choice = int(input("请选择要登陆的用户: ")) + while True: + try: + choice = int(input("请选择要登录的用户序号: ")) + if 1 <= choice <= len(files): + break + else: + print("无效的选择,请重新输入。") + except ValueError: + print("无效的选择,请重新输入。") # 读取选择的文件 selected_file = files[choice - 1] diff --git a/util/LoginUtil.py b/util/LoginUtil.py index 3e18f52..f6e46df 100644 --- a/util/LoginUtil.py +++ b/util/LoginUtil.py @@ -50,8 +50,9 @@ def QR(): def cookie(): - if Config.read_files_in_folder(): - return eval(Config.read_files_in_folder()) + select_user = Config.read_files_in_folder() + if select_user: + return eval(select_user) # 获取 QQ空间 cookie qrsig = QR() ptqrtoken = ptqrToken(qrsig)