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

460 lines
9.6 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"example.tex\n",
"填空题\n",
"选择题\n",
"解答题\n",
"\n",
"\n",
"\n",
"基础考.tex\n",
"填空题\n",
"(012033)\n",
"(012034)\n",
"(012035)\n",
"(012036)\n",
"(012037)\n",
"(012038)\n",
"(012039)\n",
"(012040)\n",
"(012041)\n",
"(012042)\n",
"(012043)\n",
"(012044)\n",
"选择题\n",
"(012045)\n",
"(012046)\n",
"(012047)\n",
"(012048)\n",
"解答题\n",
"(012049)\n",
"(012050)\n",
"(012051)\n",
"(012052)\n",
"(012053)\n",
"\n",
"\n",
"\n",
"月考01.tex\n",
"填空题\n",
"(004080)\n",
"(004122)\n",
"(004312)\n",
"(004451)\n",
"(004557)\n",
"(004276)\n",
"(030019)\n",
"(004356)\n",
"(004320)\n",
"(004359)\n",
"(030020)\n",
"(004091)\n",
"选择题\n",
"(004400)\n",
"(008101)\n",
"(004157)\n",
"(004440)\n",
"解答题\n",
"(004370)\n",
"(004224)\n",
"(004328)\n",
"(004444)\n",
"(004247)\n",
"\n",
"\n",
"\n",
"测验01.tex\n",
"填空题\n",
"(004810)\n",
"(005230)\n",
"(004108)\n",
"(004106)\n",
"(004949)\n",
"(007809)\n",
"(001339)\n",
"(020068)\n",
"选择题\n",
"(020081)\n",
"(007959)\n",
"解答题\n",
"(002859)\n",
"(011131)\n",
"\n",
"\n",
"\n",
"测验02.tex\n",
"填空题\n",
"(000486)\n",
"(000498)\n",
"(000656)\n",
"(000558)\n",
"(004622)\n",
"(005584)\n",
"(010136)\n",
"(004412)\n",
"(010133)\n",
"(000555)\n",
"(000565)\n",
"(000824)\n",
"选择题\n",
"(005196)\n",
"(002853)\n",
"(005574)\n",
"(004385)\n",
"解答题\n",
"(002881)\n",
"(002903)\n",
"(002970)\n",
"(004680)\n",
"(004184)\n",
"\n",
"\n",
"\n",
"测验03.tex\n",
"填空题\n",
"(005888)\n",
"(004248)\n",
"(005943)\n",
"(030104)\n",
"(030102)\n",
"(030101)\n",
"(004322)\n",
"选择题\n",
"(006346)\n",
"(005993)\n",
"(006061)\n",
"解答题\n",
"(003627)\n",
"(030103)\n",
"\n",
"\n",
"\n",
"测验04.tex\n",
"填空题\n",
"(001506)\n",
"(004125)\n",
"(002027)\n",
"(030152)\n",
"(004414)\n",
"(001013)\n",
"(003798)\n",
"(001253)\n",
"(001510)\n",
"(001515)\n",
"(004111)\n",
"(030153)\n",
"选择题\n",
"(001993)\n",
"(004240)\n",
"(003645)\n",
"(004116)\n",
"解答题\n",
"(004636)\n",
"(001494)\n",
"(004098)\n",
"(004424)\n",
"(004509)\n",
"\n",
"\n",
"\n",
"测验05.tex\n",
"填空题\n",
"(003632)\n",
"(003636)\n",
"(004144)\n",
"(003986)\n",
"(004081)\n",
"(004124)\n",
"(003658)\n",
"(004313)\n",
"(004278)\n",
"(004257)\n",
"(004153)\n",
"(004154)\n",
"选择题\n",
"(004365)\n",
"(004420)\n",
"(004460)\n",
"(004461)\n",
"解答题\n",
"(004485)\n",
"(030282)\n",
"(004763)\n",
"(004465)\n",
"(004466)\n",
"\n",
"\n",
"\n",
"测验06.tex\n",
"填空题\n",
"(030428)\n",
"(030449)\n",
"(030450)\n",
"(030431)\n",
"(030432)\n",
"(030433)\n",
"(030434)\n",
"(030435)\n",
"(030436)\n",
"(030437)\n",
"(030438)\n",
"(030439)\n",
"选择题\n",
"(030440)\n",
"(030441)\n",
"(030442)\n",
"(030443)\n",
"解答题\n",
"(030444)\n",
"(030445)\n",
"(030446)\n",
"\n",
"\n",
"\n",
"测验07.tex\n",
"填空题\n",
"(005304)\n",
"(004468)\n",
"(004469)\n",
"(004470)\n",
"(004471)\n",
"(004472)\n",
"(004473)\n",
"(030480)\n",
"(004475)\n",
"(004476)\n",
"(004477)\n",
"(004478)\n",
"选择题\n",
"(004479)\n",
"(004480)\n",
"(004481)\n",
"(004482)\n",
"解答题\n",
"(004484)\n",
"(004485)\n",
"(004486)\n",
"\n",
"\n",
"\n",
"测验08.tex\n",
"填空题\n",
"(012054)\n",
"(012055)\n",
"(012056)\n",
"(012057)\n",
"(012058)\n",
"(012059)\n",
"(012060)\n",
"(012061)\n",
"(012062)\n",
"(012063)\n",
"(012064)\n",
"(012065)\n",
"选择题\n",
"(012066)\n",
"(012067)\n",
"(012068)\n",
"(012069)\n",
"解答题\n",
"(012070)\n",
"(012071)\n",
"(012072)\n",
"(012073)\n",
"(012074)\n",
"\n",
"\n",
"\n",
"测验09.tex\n",
"填空题\n",
"(012075)\n",
"(012076)\n",
"(012077)\n",
"(012078)\n",
"(012079)\n",
"(012080)\n",
"(012081)\n",
"(012082)\n",
"(012083)\n",
"(012084)\n",
"(012085)\n",
"(012086)\n",
"选择题\n",
"(012087)\n",
"(012088)\n",
"(012089)\n",
"(012090)\n",
"解答题\n",
"(012091)\n",
"(012092)\n",
"(012093)\n",
"(012094)\n",
"(012095)\n",
"\n",
"\n",
"\n",
"测验10.tex\n",
"填空题\n",
"(012096)\n",
"(012097)\n",
"(012098)\n",
"(012099)\n",
"(012100)\n",
"(012101)\n",
"(012102)\n",
"(012103)\n",
"(012104)\n",
"(012105)\n",
"(012106)\n",
"(012107)\n",
"选择题\n",
"(012108)\n",
"(012109)\n",
"(012110)\n",
"(012111)\n",
"解答题\n",
"(012112)\n",
"(012113)\n",
"(012114)\n",
"(012115)\n",
"(012116)\n",
"\n",
"\n",
"\n",
"测验11.tex\n",
"填空题\n",
"(012203)\n",
"(012205)\n",
"(012207)\n",
"(012208)\n",
"(012209)\n",
"(012210)\n",
"(012211)\n",
"(012212)\n",
"(012213)\n",
"(012214)\n",
"选择题\n",
"(012215)\n",
"(012216)\n",
"(012217)\n",
"(012218)\n",
"解答题\n",
"(012219)\n",
"(012220)\n",
"(030501)\n",
"\n",
"\n",
"\n",
"线上测验01.tex\n",
"填空题\n",
"(000382)\n",
"(001997)\n",
"(002011)\n",
"(002081)\n",
"(007042)\n",
"(030157)\n",
"(003841)\n",
"(030155)\n",
"(030154)\n",
"(003702)\n",
"选择题\n",
"(007065)\n",
"(002024)\n",
"解答题\n",
"(001884)\n",
"(001915)\n",
"(030156)\n",
"\n",
"\n",
"\n"
]
}
],
"source": [
"import os,re\n",
"\"---此处输入文件夹名---\"\n",
"directory = r\"C:\\Users\\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.15 ('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.8.15"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "42dd566da87765ddbe9b5c5b483063747fec4aacc5469ad554706e4b742e67b2"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}