From 2598ebcb8beda730293b1d5fd748efcfbb8c6969 Mon Sep 17 00:00:00 2001 From: 4Aiur <14359997+4Aiur@users.noreply.github.com> Date: Wed, 11 Sep 2024 15:07:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9Linux=EF=BC=8C=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Dmodule=20'os'=20has=20no=20attribute=20'startfile'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index a528cb6..2a76db5 100644 --- a/main.py +++ b/main.py @@ -10,6 +10,7 @@ import re from tqdm import trange,tqdm import requests import time +import platform # 信号处理函数 def signal_handler(signal, frame): @@ -75,9 +76,17 @@ def save_data(): print('\033[36m' + '留言列表共有 ' + str(len(leave_message)) + ' 条留言' + '\033[0m') print('\033[32m' + '其他列表共有 ' + str(len(other_message)) + ' 条内容' + '\033[0m') print('\033[36m' + '图片列表共有 ' + str(len(os.listdir(pic_save_path))) + ' 张图片' + '\033[0m') - current_directory = os.getcwd() - os.startfile(current_directory + user_save_path[1:]) - os.system('pause') + + if platform.system() == "Windows": + current_directory = os.getcwd() + os.startfile(current_directory + user_save_path[1:]) + os.system('pause') + else: + # 兼容Linux + full_path = os.path.abspath(user_save_path) + print("数据已经写入"+ full_path) + + if __name__ == '__main__': try: