mirror of
https://github.com/LibraHp/GetQzonehistory.git
synced 2025-02-23 05:49:07 +00:00
Merge pull request #16 from Xigua7i/fix-start_file_os
Fix: 修复处理结束后在windows外的系统不能打开文件问题
This commit is contained in:
commit
d7387a9345
20
main.py
20
main.py
@ -1,3 +1,5 @@
|
|||||||
|
import platform
|
||||||
|
import subprocess
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from tqdm import trange
|
from tqdm import trange
|
||||||
import util.RequestUtil as Request
|
import util.RequestUtil as Request
|
||||||
@ -76,9 +78,25 @@ def save_data():
|
|||||||
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')
|
||||||
current_directory = os.getcwd()
|
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')
|
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__':
|
if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
user_info = Request.get_login_user_info()
|
user_info = Request.get_login_user_info()
|
||||||
|
BIN
resource/.DS_Store
vendored
Normal file
BIN
resource/.DS_Store
vendored
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user