This repository has been archived on 2024-06-23. You can view files and clone it, but cannot push or open issues or pull requests.
mathdeptv2/工具v2/单一题目转成图片文件.py

20 lines
547 B
Python

id = "2024"
from database_tools import *
pro_dict = load_dict("../题库0.3/Problems.json")
content = pro_dict[id.zfill(6)]["content"]
latex_raw = ReadTextFile("模板文件/独立文件模板.txt")
latexdata = StringSubstitute(r"<<待替换\d*>>",latex_raw,[content])
try:
os.mkdir("临时文件/pics")
except:
pass
SaveTextFile(latexdata,"临时文件/pics/temp.tex")
os.system("xelatex -interaction=batchmode -output-directory=临时文件/pics temp.tex")
os.chdir("临时文件/pics")
os.system("pdftocairo temp.pdf -png -r 600")