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