20221205 afternoon

This commit is contained in:
Wang Weiye 2022-12-05 19:42:39 +08:00
parent d4cce4757d
commit edc485d161
1 changed files with 25 additions and 10 deletions

View File

@ -2,7 +2,7 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 25,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -11,7 +11,7 @@
"0" "0"
] ]
}, },
"execution_count": 1, "execution_count": 25,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -19,15 +19,30 @@
"source": [ "source": [
"import os,re,json\n", "import os,re,json\n",
"# 这里修改题目id, 可以不满6位\n", "# 这里修改题目id, 可以不满6位\n",
"id = 5900\n", "id = 1\n",
"\n", "\n",
"index = str(id).zfill(6)\n", "index = str(id).zfill(6)\n",
"with open(r\"../题库0.3/Problems.json\",\"r\",encoding = \"utf8\") as f:\n", "with open(r\"../题库0.3/Problems.json\",\"r\",encoding = \"utf8\") as f:\n",
" database = f.read()\n", " database = f.read()\n",
"line = '\"id\": \"'+index+'\",'\n", "pro_dict = json.loads(database)\n",
"before = database[:database.index(line)]\n", "problem = pro_dict[index]\n",
"position = len(re.findall(r\"\\n\",before))\n", "with open(r\"临时文件/problem_edit.json\",\"w\",encoding=\"u8\") as f:\n",
"os.system(r\"code -g ../题库0.3/Problems.json:\" +str(position))" " 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": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Python 3.8.8 ('base')", "display_name": "Python 3.9.7 ('base')",
"language": "python", "language": "python",
"name": "python3" "name": "python3"
}, },
@ -54,12 +69,12 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.8.8" "version": "3.9.7"
}, },
"orig_nbformat": 4, "orig_nbformat": 4,
"vscode": { "vscode": {
"interpreter": { "interpreter": {
"hash": "d311ffef239beb3b8f3764271728f3972d7b090c974f8e972fcdeedf230299ac" "hash": "e4cce46d6be9934fbd27f9ca0432556941ea5bdf741d4f4d64c6cd7f8dfa8fba"
} }
} }
}, },