兼容Linux, 修复module 'os' has no attribute 'startfile'

This commit is contained in:
4Aiur 2024-09-11 15:07:51 +08:00
parent e39eb40d06
commit 2598ebcb8b
No known key found for this signature in database

View File

@ -10,6 +10,7 @@ import re
from tqdm import trange,tqdm from tqdm import trange,tqdm
import requests import requests
import time import time
import platform
# 信号处理函数 # 信号处理函数
def signal_handler(signal, frame): def signal_handler(signal, frame):
@ -75,9 +76,17 @@ def save_data():
print('\033[36m' + '留言列表共有 ' + str(len(leave_message)) + ' 条留言' + '\033[0m') print('\033[36m' + '留言列表共有 ' + str(len(leave_message)) + ' 条留言' + '\033[0m')
print('\033[32m' + '其他列表共有 ' + str(len(other_message)) + ' 条内容' + '\033[0m') print('\033[32m' + '其他列表共有 ' + str(len(other_message)) + ' 条内容' + '\033[0m')
print('\033[36m' + '图片列表共有 ' + str(len(os.listdir(pic_save_path))) + ' 张图片' + '\033[0m') print('\033[36m' + '图片列表共有 ' + str(len(os.listdir(pic_save_path))) + ' 张图片' + '\033[0m')
if platform.system() == "Windows":
current_directory = os.getcwd() current_directory = os.getcwd()
os.startfile(current_directory + user_save_path[1:]) os.startfile(current_directory + user_save_path[1:])
os.system('pause') os.system('pause')
else:
# 兼容Linux
full_path = os.path.abspath(user_save_path)
print("数据已经写入"+ full_path)
if __name__ == '__main__': if __name__ == '__main__':
try: try: