99 lines
2.6 KiB
Plaintext
99 lines
2.6 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"010944 True\n",
|
|
"030017 True\n",
|
|
"010946 True\n",
|
|
"010947 True\n",
|
|
"010948 True\n",
|
|
"010949 True\n",
|
|
"010950 True\n",
|
|
"010951 True\n",
|
|
"010952 True\n",
|
|
"010953 True\n",
|
|
"010954 True\n",
|
|
"010955 True\n",
|
|
"010956 True\n",
|
|
"002874 True\n",
|
|
"010958 True\n",
|
|
"010959 True\n",
|
|
"010960 True\n",
|
|
"010961 True\n",
|
|
"010962 True\n",
|
|
"010963 True\n",
|
|
"010964 True\n",
|
|
"010944,030017,010946,010947,010948,010949,010950,010951,010952,010953,010954,010955,010956,002874,010958,010959,010960,010961,010962,010963,010964\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import os,re,json\n",
|
|
"\n",
|
|
"#读取题库json文件并转化为字典\n",
|
|
"with open(r\"../题库0.3/Problems.json\",\"r\",encoding = \"utf8\") as f:\n",
|
|
" database = f.read()\n",
|
|
"pro_dict = json.loads(database)\n",
|
|
"with open(r\"C:\\Users\\Wang Weiye\\Documents\\wwy sync\\23届\\上学期周末卷\\周末卷02.tex\",\"r\",encoding = \"u8\") as f:\n",
|
|
" data = f.read()\n",
|
|
"problems_raw = re.findall(r\"\\(([\\d]{6})\\)\\}([\\s\\S]*?)\\n\\n\",data)\n",
|
|
"problems_list = []\n",
|
|
"for p in problems_raw:\n",
|
|
" if \"vspace\" in p[1]:\n",
|
|
" problems_list.append((p[0],p[1][:p[1].index(r\"\\vspace\")]))\n",
|
|
" else:\n",
|
|
" problems_list.append(p)\n",
|
|
" \n",
|
|
"for p in problems_list:\n",
|
|
" print(p[0],pro_dict[p[0]][\"content\"].strip() == p[1].strip())\n",
|
|
" if not pro_dict[p[0]][\"content\"].strip() == p[1].strip():\n",
|
|
" print(pro_dict[p[0]][\"content\"].strip())\n",
|
|
" print(p[1].strip())\n",
|
|
"\n",
|
|
"print(\",\".join(re.findall(r\"\\(([\\d]{6})\\)\",data)))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3.9.7 ('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.9.7"
|
|
},
|
|
"orig_nbformat": 4,
|
|
"vscode": {
|
|
"interpreter": {
|
|
"hash": "e4cce46d6be9934fbd27f9ca0432556941ea5bdf741d4f4d64c6cd7f8dfa8fba"
|
|
}
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|