From f23b4183d9abe9503615a364a3a3b99ec31750e7 Mon Sep 17 00:00:00 2001 From: wangweiye7840 Date: Fri, 15 Mar 2024 13:36:42 +0800 Subject: [PATCH] =?UTF-8?q?database=5Ftools=E4=B8=AD=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=B7=A8=E5=B9=B3=E5=8F=B0=E6=89=93=E5=BC=80=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=88=96=E6=96=87=E4=BB=B6=E5=A4=B9=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v2/database_tools.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/工具v2/database_tools.py b/工具v2/database_tools.py index ff83e02d..b02e0bb0 100644 --- a/工具v2/database_tools.py +++ b/工具v2/database_tools.py @@ -1,4 +1,4 @@ -import json,re,os,Levenshtein,fitz,time,sys +import json,re,os,Levenshtein,fitz,time,sys,subprocess import pandas as pd import pyperclip @@ -2122,5 +2122,23 @@ def TitleIDTupleListtoString(correspoinding_list): #将(标题,题号字符串) output_string += f"{count}. {corresp[0]}: {corresp[1]}\n" return output_string +def startfile(filepath): #跨平台打开文件或文件夹 + isfile = os.path.isfile(filepath) + osname = sys.platform + if osname == "win32": + if not isfile: + ret = subprocess.Popen(["explorer",filepath]) + if isfile: + ret = subprocess.Popen(["start",filepath], shell=True) + elif osname == "darwin": + ret = subprocess.Popen(["open",filepath]) + elif osname == "linux": + ret = subprocess.Popen(["xdg-open",filepath]) + return ret + + + + + if __name__ == "__main__": print("数据库工具, import用.") \ No newline at end of file