20230319 afternoon
This commit is contained in:
parent
5d3adababf
commit
01d8266e0a
|
|
@ -65,7 +65,6 @@ A.~#1 &B.~#2& C.~#3& D.~#4
|
|||
\end{center}
|
||||
|
||||
|
||||
%\section{课前练习}
|
||||
|
||||
\begin{enumerate}[1.]
|
||||
待替换1
|
||||
|
|
|
|||
|
|
@ -0,0 +1,86 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"0\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import os,re,json\n",
|
||||
"\n",
|
||||
"filename = r\"C:\\Users\\weiye\\Documents\\wwy sync\\23届\\第二轮复习讲义\\09_立体几何综合.tex\"\n",
|
||||
"outfilename = \"立体几何综合答案\"\n",
|
||||
"pdf_dir = \"临时文件\"\n",
|
||||
"\n",
|
||||
"with open(filename,\"r\",encoding = \"u8\") as f:\n",
|
||||
" data = f.read()\n",
|
||||
"with open(\"../题库0.3/Problems.json\",\"r\",encoding = \"u8\") as f:\n",
|
||||
" pro_dict = json.loads(f.read())\n",
|
||||
"\n",
|
||||
"ids = re.findall(r\"\\((\\d{6})\\)\",data)\n",
|
||||
"\n",
|
||||
"output_data = \"\"\n",
|
||||
"for id in ids:\n",
|
||||
" problemset = pro_dict[id]\n",
|
||||
" content = problemset[\"content\"]\n",
|
||||
" solution = problemset[\"solution\"]\n",
|
||||
" answer = \"\\\\textcolor{red}{\" + (problemset[\"ans\"] if problemset[\"ans\"] != \"\" else \"\\\\textcolor{blue}{暂无答案\") + \"}\"\n",
|
||||
" output_data += \"\\\\item \" + \"(\"+id+\") \" + content + \"\\n\\n\" + \"答案: \" + answer + \"\\n\\n\" + (\"\" if solution == \"\" else (\"解答或提示: \" + solution)) + \"\\n\\n\"\n",
|
||||
"\n",
|
||||
"with open(\"模板文件/日常选题讲义模板.txt\",\"r\",encoding = \"u8\") as f:\n",
|
||||
" outlatex = f.read()\n",
|
||||
"\n",
|
||||
"outlatex = outlatex.replace(\"待替换1\",output_data)\n",
|
||||
"outlatex = outlatex.replace(\"标题文字待处理\",outfilename)\n",
|
||||
"\n",
|
||||
"outfile = os.path.join(\"临时文件\",outfilename+\".tex\")\n",
|
||||
"with open(outfile,\"w\",encoding=\"u8\") as f:\n",
|
||||
" f.write(outlatex)\n",
|
||||
"\n",
|
||||
"outfile = outfile.replace(\"\\\\\",\"/\")\n",
|
||||
"\n",
|
||||
"os.system(\"xelatex -interaction=batchmode -output-directory=\" + pdf_dir + \" \"+ outfile)\n",
|
||||
"print(os.system(\"xelatex -interaction=batchmode -output-directory=\" + pdf_dir + \" \"+ outfile))\n",
|
||||
"\n",
|
||||
" "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "mathdept",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.15"
|
||||
},
|
||||
"orig_nbformat": 4
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
Reference in New Issue