Merge pull request #16 from Xigua7i/fix-start_file_os

Fix: 修复处理结束后在windows外的系统不能打开文件问题
This commit is contained in:
LibraHp_0928 2024-09-11 15:33:12 +08:00 committed by GitHub
commit d7387a9345
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 1 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

20
main.py
View File

@ -1,3 +1,5 @@
import platform
import subprocess
from bs4 import BeautifulSoup
from tqdm import trange
import util.RequestUtil as Request
@ -76,8 +78,24 @@ def save_data():
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.startfile(current_directory + user_save_path[1:])
open_file(current_directory + user_save_path[1:])
os.system('pause')
def open_file(file_path):
# 检查操作系统
if platform.system() == 'Windows':
# Windows 系统使用 os.startfile
os.startfile(file_path)
elif platform.system() == 'Darwin':
# macOS 系统使用 subprocess 和 open 命令
subprocess.run(['open', file_path])
elif platform.system() == 'Linux':
# Linux 系统使用 subprocess 和 xdg-open 命令
subprocess.run(['xdg-open', file_path])
else:
print(f"Unsupported OS: {platform.system()}")
if __name__ == '__main__':
try:

BIN
resource/.DS_Store vendored Normal file

Binary file not shown.