{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "题号: 012096 , 字段: ans 中已修改数据: $\\{-1,0\\}$\n", "题号: 012097 , 字段: ans 中已修改数据: $2$\n", "题号: 012098 , 字段: ans 中已修改数据: $(1,-2,-3)$\n", "题号: 012099 , 字段: ans 中已修改数据: $3$\n", "题号: 012100 , 字段: ans 中已修改数据: $69$\n", "题号: 012101 , 字段: ans 中已修改数据: $-\\dfrac 43$\n", "题号: 012102 , 字段: ans 中已修改数据: $\\dfrac 12$\n", "题号: 012103 , 字段: ans 中已修改数据: $\\dfrac\\pi 6$或$\\dfrac{5\\pi}6$\n", "题号: 012104 , 字段: ans 中已修改数据: $(-3,-1)\\cup (0,1)$\n", "题号: 012105 , 字段: ans 中已修改数据: $\\dfrac 6{25}$\n", "题号: 012106 , 字段: ans 中已修改数据: $\\sqrt{3}$\n", "题号: 012107 , 字段: ans 中已修改数据: $(-1,1-\\sqrt{3}]$\n", "题号: 012108 , 字段: ans 中已修改数据: B\n", "题号: 012109 , 字段: ans 中已修改数据: D\n", "题号: 012110 , 字段: ans 中已修改数据: C\n", "题号: 012111 , 字段: ans 中已修改数据: C\n", "题号: 012112 , 字段: ans 中已修改数据: (1) 公差为$3$; (2) $a_1$的所有可能的值为$18,19,20$\n", "题号: 012113 , 字段: ans 中已修改数据: (1) 证明略; (2) $\\dfrac 13$\n", "题号: 012114 , 字段: ans 中已修改数据: (1) (示例)王先生可能需要考虑的因素有:\\\\\n", "\\textcircled{1} 未来月租金的变化;\\\\\n", "\\textcircled{2} 找到承租人的时长的变化;\\\\\n", "\\textcircled{3} 未来租客的租期长短;\\\\\n", "\\textcircled{4} 房屋是否未来三年内可以用于出租;\\\\\n", "\\textcircled{5} 换租客的过程中是否需要重新装修;\n", "\\textcircled{6} 寻租过程中的时间、精力成本等.\\\\\n", "(2) 言之有理即可\n", "题号: 012115 , 字段: ans 中已修改数据: (1) $y=x+1$; (2) 面积的最大值为$2$, 此时$l:y=0$; (3) 当$\\delta_{F_1}\\cdot \\delta_{F_2}>b^2$($=b^2$, $ 0]\n", " for record in datalist:\n", " id = re.findall(r\"^[\\d]{1,}\",record)[0]\n", " data = record[len(id):].strip()\n", " id = id.zfill(6)\n", " if not id in pro_dict:\n", " print(\"题号:\",id,\"不在数据库中.\")\n", " break\n", " \n", " #字符串类型字段添加数据\n", " elif field_type == str and data in pro_dict[id][field]:\n", " print(\"题号:\",id,\", 字段:\",field,\"中已有该数据:\",data)\n", " elif field_type == str and not data in pro_dict[id][field] and not field == \"ans\" and not field == \"space\":\n", " origin_data = pro_dict[id][field]\n", " new_data = trim(origin_data + \"\\n\" + data)\n", " pro_dict[id][field] = new_data\n", " print(\"题号:\",id,\", 字段:\",field,\"中已添加数据:\",data)\n", " elif field_type == str and not data in pro_dict[id][field] and field == \"ans\" or field == \"space\":\n", " pro_dict[id][field] = data\n", " print(\"题号:\",id,\", 字段:\",field,\"中已修改数据:\",data)\n", " \n", " #数值类型字段添加数据\n", " elif (field_type == int or field_type == float) and abs(float(data) - pro_dict[id][field])<0.01:\n", " print(\"题号:\",id,\", 字段:\",field,\"中已有该数据:\",FloatToInt(data))\n", " elif (field_type == int or field_type == float) and abs(float(data) - pro_dict[id][field])>=0.01:\n", " pro_dict[id][field] = FloatToInt(data)\n", " print(\"题号:\",id,\", 字段:\",field,\"中已修改数据:\",FloatToInt(data))\n", " \n", " #列表类型字段添加数据\n", " elif field_type == list:\n", " cell_data_list = [d.strip() for d in data.split(\"\\n\")]\n", " for cell_data in cell_data_list:\n", " if cell_data in pro_dict[id][field]:\n", " print(\"题号:\",id,\", 字段:\",field,\"中已有该数据:\",cell_data)\n", " elif not field == \"objs\":\n", " pro_dict[id][field].append(cell_data)\n", " print(\"题号:\",id,\", 字段:\",field,\"中已添加数据:\",cell_data)\n", " else:\n", " if not cell_data in obj_dict and not cell_data.upper() == \"KNONE\":\n", " print(\"题号:\",id,\", 字段:\",field,\"目标编号有误:\",cell_data)\n", " else:\n", " pro_dict[id][field].append(cell_data.upper())\n", " print(\"题号:\",id,\", 字段:\",field,\"中已添加数据:\",cell_data.upper())\n", "\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))" ] }, { "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 }