From 58ec422bb1b7ea0f1471b5f130f3173a00d76886 Mon Sep 17 00:00:00 2001 From: "weiye.wang" Date: Wed, 21 Feb 2024 20:56:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E9=80=92=E5=BD=92?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=96=87=E4=BB=B6=E5=A4=B9=20makedir=20?= =?UTF-8?q?=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 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/工具v2/database_tools.py b/工具v2/database_tools.py index 0539a7dd..e3082bbb 100644 --- a/工具v2/database_tools.py +++ b/工具v2/database_tools.py @@ -2022,5 +2022,23 @@ def ExportIDList(filepath): #从.tex或.pdf文件获取题目序号和ID的对 output += ",".join(currentoutput)+"\n\n" return output +def makedir(dirpath): #递归创建文件夹 + dirpath = dirpath.strip().replace("\\","/") + dirlist_raw = dirpath.split("/") + if ":" in dirlist_raw[0]: + dirlist_raw[1] = dirlist_raw[0] + "/" + dirlist_raw[1] + dirlist = dirlist_raw[1:].copy() + else: + dirlist = dirlist_raw.copy() + for i in range(len(dirlist)): + if not i == 0: + dirlist[i] = dirlist[i-1] + "/" + dirlist[i] + for dpath in dirlist: + try: + os.mkdir(dpath) + except: + pass + return dirlist + if __name__ == "__main__": print("数据库工具, import用.") \ No newline at end of file