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/工具/生成文件夹下的题号清单.ipynb

228 lines
5.2 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"赋能01.tex\n",
"0.95}{赋能01答题纸.png\n",
"(000326)\n",
"(000327)\n",
"(000328)\n",
"(000329)\n",
"(030021)\n",
"(000331)\n",
"(000332)\n",
"(030022)\n",
"(030026)\n",
"(000335)\n",
"\n",
"\n",
"\n",
"赋能02.tex\n",
"0.95}{赋能02答题纸.png\n",
"(001750)\n",
"(000337)\n",
"(002675)\n",
"(000339)\n",
"(000340)\n",
"(000341)\n",
"(000342)\n",
"(000343)\n",
"(000344)\n",
"(000345)\n",
"\n",
"\n",
"\n",
"赋能03.tex\n",
"0.95}{赋能03答题纸.png\n",
"(000346)\n",
"(000347)\n",
"(000348)\n",
"(000349)\n",
"(030071)\n",
"(000351)\n",
"(000352)\n",
"(030072)\n",
"(000354)\n",
"(030073)\n",
"\n",
"\n",
"\n",
"赋能04.tex\n",
"0.95}{赋能04答题纸.png\n",
"(000356)\n",
"(000357)\n",
"(030074)\n",
"(000359)\n",
"(000360)\n",
"(000361)\n",
"(000362)\n",
"(000363)\n",
"(000364)\n",
"(030075)\n",
"\n",
"\n",
"\n",
"赋能05.tex\n",
"0.95}{赋能05答题纸.png\n",
"(000366)\n",
"(000367)\n",
"(000368)\n",
"(000369)\n",
"(030281)\n",
"(000371)\n",
"(000372)\n",
"(000373)\n",
"(000374)\n",
"(000375)\n",
"\n",
"\n",
"\n",
"赋能06.tex\n",
"0.95}{赋能06答题纸.png\n",
"(001772)\n",
"(000377)\n",
"(000378)\n",
"(008356)\n",
"(008334)\n",
"(008080)\n",
"(000382)\n",
"(000383)\n",
"(000384)\n",
"(000385)\n",
"\n",
"\n",
"\n",
"赋能07.tex\n",
"0.95}{赋能07答题纸.png\n",
"(000386)\n",
"(000387)\n",
"(000388)\n",
"(000389)\n",
"(000390)\n",
"(000391)\n",
"(000392)\n",
"(000393)\n",
"(000394)\n",
"(000395)\n",
"\n",
"\n",
"\n",
"赋能08.tex\n",
"0.95}{赋能08答题纸.png\n",
"(000396)\n",
"(000397)\n",
"(000398)\n",
"(000399)\n",
"(011012)\n",
"(000401)\n",
"(000402)\n",
"(000403)\n",
"(000404)\n",
"(000405)\n",
"\n",
"\n",
"\n",
"赋能09.tex\n",
"0.95}{赋能09答题纸.png\n",
"(000406)\n",
"(000407)\n",
"(000408)\n",
"(011585)\n",
"(000410)\n",
"(000411)\n",
"(000412)\n",
"(000413)\n",
"(000414)\n",
"(000415)\n",
"\n",
"\n",
"\n"
]
}
],
"source": [
"import os,re\n",
"\"---此处输入文件夹名---\"\n",
"directory = r\"C:\\Users\\wang weiye\\Documents\\wwy sync\\23届\\赋能\"\n",
"\"---文件夹名输入结束---\"\n",
"\n",
"filelist = [filename for filename in os.listdir(directory) if \".tex\" in filename]\n",
"\n",
"output = \"\"\n",
"\n",
"for filename in filelist:\n",
" print(filename)\n",
" output += filename + \"\\n\"\n",
" with open(os.path.join(directory,filename),\"r\",encoding = \"u8\") as f:\n",
" try:\n",
" data = re.findall(r\"\\\\begin{document}([\\s\\S]*?)\\\\end{document}\",f.read())[0]\n",
" data = data.replace(r\"\\section\",\"endsecbeginsec\") + \"endsec\"\n",
" if not \"beginsec\" in data: \n",
" data = \"beginsec\" + data\n",
" sectionlist = re.findall(r\"beginsec([\\s\\S]*?)endsec\",data)\n",
" for sec in sectionlist:\n",
" secname = re.findall(r\"{([\\S]*)}\",sec)[0]\n",
" output += secname + \"\\n\"\n",
" print(secname)\n",
" for id in re.findall(r\"\\(\\d{6}\\)\",sec):\n",
" print(id)\n",
" output += id + \"\\n\"\n",
" except:\n",
" pass \n",
" output += \"\\n\\n\"\n",
" print(\"\\n\\n\")\n",
"\n",
"with open(os.path.join(directory,\"题号清点.txt\"),\"w\",encoding = \"u8\") as f:\n",
" f.write(output + \"\\n\\n\\n以下题号不含括号\\n\\n\\n\" + output.replace(\"(\",\"\").replace(\")\",\"\"))\n",
"\n",
" \n",
"\n",
"\n",
" \n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.8.8 ('base')",
"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.8.8"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "d311ffef239beb3b8f3764271728f3972d7b090c974f8e972fcdeedf230299ac"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}