102 lines
2.3 KiB
Plaintext
102 lines
2.3 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "488c74e2-3b75-4274-8d9a-4503f367b5ca",
|
|
"metadata": {},
|
|
"source": [
|
|
"# 高考志愿查询"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "8913f77b-bbd5-4959-b5a4-3214732f8480",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 按位次模糊查询专业"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "be2371be-89f5-4879-82a9-4a1d9e6376d3",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import pymongo\n",
|
|
"import re\n",
|
|
"\n",
|
|
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
|
|
"mydb = myclient[\"gaokao\"]\n",
|
|
"mycol = mydb[\"admission_2020\"]\n",
|
|
"\n",
|
|
"m_zhuanye = '医学'\n",
|
|
"m_rank1 = 11000\n",
|
|
"m_rank2 = 15000\n",
|
|
"\n",
|
|
"myquery = {'spe_name':re.compile(m_zhuanye),'rank_min':{\"$gte\": m_rank1,\"$lte\": m_rank2}}\n",
|
|
"i = 1\n",
|
|
"for x in mycol.find(myquery,{\"_id\": 0, }):\n",
|
|
" print(i,x['col_name'],x['spe_name'],x['rank_min'])\n",
|
|
" i += 1\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "2731820f-b81e-4d7e-8f53-a2501d9c943f",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 按分数模糊查询专业"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "07dbb641-d594-4c7c-92da-045a5370e6e9",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import pymongo\n",
|
|
"import re\n",
|
|
"\n",
|
|
"myclient = pymongo.MongoClient('mongodb://localhost:27017/')\n",
|
|
"mydb = myclient[\"gaokao\"]\n",
|
|
"mycol = mydb[\"admission_2020\"]\n",
|
|
"\n",
|
|
"m_zhuanye = '医学'\n",
|
|
"m_fenshu = 600\n",
|
|
"\n",
|
|
"myquery = {'spe_name':re.compile(m_zhuanye),'num_min':{\"$gte\": m_fenshu}}\n",
|
|
"i = 1\n",
|
|
"for x in mycol.find(myquery,{\"_id\": 0, }):\n",
|
|
" print(i,x['col_name'],x['spe_name'],x['num_min'])\n",
|
|
" i += 1\n"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"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.10"
|
|
},
|
|
"toc-autonumbering": true,
|
|
"toc-showmarkdowntxt": true,
|
|
"toc-showtags": false
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|