From 5c0f92a64ee8b2297179c275749fbc0c8c979e29 Mon Sep 17 00:00:00 2001 From: "weiye.wang" Date: Wed, 21 Feb 2024 21:00:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=B2=E6=9C=89=E5=B7=A5=E5=85=B7v2=E7=9A=84?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E4=B8=AD=E7=9A=84os.mkdir()=E5=9D=87?= =?UTF-8?q?=E6=94=B9=E4=B8=BAmakedir()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v2/database_tools.py | 2 +- 工具v2/单一题目转成图片文件.py | 6 ++---- 工具v2/收集使用记录.py | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/工具v2/database_tools.py b/工具v2/database_tools.py index e3082bbb..3ba40654 100644 --- a/工具v2/database_tools.py +++ b/工具v2/database_tools.py @@ -19,7 +19,7 @@ def ReadTextFile(filepath): #读取文本格式的文件 def SaveTextFile(data,filepath): #写入文本格式的文件 pathname = os.path.dirname(filepath) if not os.path.exists(pathname): - os.mkdir(pathname) + makedir(pathname) with open(filepath,"w",encoding="u8") as f: f.write(data) return filepath #返回文件名 diff --git a/工具v2/单一题目转成图片文件.py b/工具v2/单一题目转成图片文件.py index ba0d35b2..a8dced27 100644 --- a/工具v2/单一题目转成图片文件.py +++ b/工具v2/单一题目转成图片文件.py @@ -16,10 +16,8 @@ content = pro_dict[id.zfill(6)]["content"] latex_raw = ReadTextFile("模板文件/独立文件模板.txt") latexdata = StringSubstitute(r"<<待替换\d*>>",latex_raw,[content]) -try: - os.mkdir("临时文件/pics") -except: - pass +makedir("临时文件/pics") + SaveTextFile(latexdata,"临时文件/pics/temp.tex") os.system("xelatex -interaction=batchmode -output-directory=临时文件/pics temp.tex") diff --git a/工具v2/收集使用记录.py b/工具v2/收集使用记录.py index 895e016a..4bcbb385 100644 --- a/工具v2/收集使用记录.py +++ b/工具v2/收集使用记录.py @@ -17,9 +17,9 @@ answersheetseekingpath = "../备课组" try: shutil.rmtree(tempdir) - os.mkdir(tempdir) except: pass +makedir(tempdir)