20221205 afternoon
This commit is contained in:
parent
d4cce4757d
commit
edc485d161
|
|
@ -2,7 +2,7 @@
|
|||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": 25,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
"0"
|
||||
]
|
||||
},
|
||||
"execution_count": 1,
|
||||
"execution_count": 25,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
|
|
@ -19,15 +19,30 @@
|
|||
"source": [
|
||||
"import os,re,json\n",
|
||||
"# 这里修改题目id, 可以不满6位\n",
|
||||
"id = 5900\n",
|
||||
"id = 1\n",
|
||||
"\n",
|
||||
"index = str(id).zfill(6)\n",
|
||||
"with open(r\"../题库0.3/Problems.json\",\"r\",encoding = \"utf8\") as f:\n",
|
||||
" database = f.read()\n",
|
||||
"line = '\"id\": \"'+index+'\",'\n",
|
||||
"before = database[:database.index(line)]\n",
|
||||
"position = len(re.findall(r\"\\n\",before))\n",
|
||||
"os.system(r\"code -g ../题库0.3/Problems.json:\" +str(position))"
|
||||
"pro_dict = json.loads(database)\n",
|
||||
"problem = pro_dict[index]\n",
|
||||
"with open(r\"临时文件/problem_edit.json\",\"w\",encoding=\"u8\") as f:\n",
|
||||
" f.write(json.dumps(problem,indent = 4,ensure_ascii=False))\n",
|
||||
"os.system(r\"code -g 临时文件/problem_edit.json\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 26,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"with open(r\"临时文件/problem_edit.json\",\"r\",encoding=\"u8\") as f:\n",
|
||||
" datanew = f.read()\n",
|
||||
"new_pro = json.loads(datanew)\n",
|
||||
"pro_dict[index] = new_pro.copy()\n",
|
||||
"with open(r\"../题库0.3/Problems.json\",\"w\",encoding = \"utf8\") as f:\n",
|
||||
" f.write(json.dumps(pro_dict,indent = 4,ensure_ascii=False))"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
@ -40,7 +55,7 @@
|
|||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3.8.8 ('base')",
|
||||
"display_name": "Python 3.9.7 ('base')",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
|
|
@ -54,12 +69,12 @@
|
|||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.8.8"
|
||||
"version": "3.9.7"
|
||||
},
|
||||
"orig_nbformat": 4,
|
||||
"vscode": {
|
||||
"interpreter": {
|
||||
"hash": "d311ffef239beb3b8f3764271728f3972d7b090c974f8e972fcdeedf230299ac"
|
||||
"hash": "e4cce46d6be9934fbd27f9ca0432556941ea5bdf741d4f4d64c6cd7f8dfa8fba"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Reference in New Issue