20230321
This commit is contained in:
1 parent
1a56946520
commit
045d2f61d5
1 file changed
+380
-57
+380
-57
@@ -4,7 +4,6 @@
|
||||
"cell_type": "markdown",
|
||||
"id": "4b749231-7ab9-4dcd-8cfd-7b9be485d3c6",
|
||||
"metadata": {
|
||||
"jp-MarkdownHeadingCollapsed": true,
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
@@ -88,7 +87,6 @@
|
||||
"cell_type": "markdown",
|
||||
"id": "2494ff3b-f52f-4933-9879-1b47857d8c67",
|
||||
"metadata": {
|
||||
"jp-MarkdownHeadingCollapsed": true,
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
@@ -284,7 +282,6 @@
|
||||
"cell_type": "markdown",
|
||||
"id": "231a0872-34ac-4121-870e-ba398a158576",
|
||||
"metadata": {
|
||||
"jp-MarkdownHeadingCollapsed": true,
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
@@ -350,7 +347,6 @@
|
||||
"cell_type": "markdown",
|
||||
"id": "0bef4bd3-99e8-4a2d-a418-77f832b1254a",
|
||||
"metadata": {
|
||||
"jp-MarkdownHeadingCollapsed": true,
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
@@ -403,7 +399,6 @@
|
||||
"cell_type": "markdown",
|
||||
"id": "b1462a26-59f8-4e5f-8fb9-d927059e0747",
|
||||
"metadata": {
|
||||
"jp-MarkdownHeadingCollapsed": true,
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
@@ -625,16 +620,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": null,
|
||||
"id": "69300248-e60f-4086-9eb9-2a61e91b5957",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-03-15T00:20:11.350101Z",
|
||||
"iopub.status.busy": "2023-03-15T00:20:11.349391Z",
|
||||
"iopub.status.idle": "2023-03-15T00:20:11.509018Z",
|
||||
"shell.execute_reply": "2023-03-15T00:20:11.508290Z",
|
||||
"shell.execute_reply.started": "2023-03-15T00:20:11.350074Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
@@ -811,52 +799,12 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"execution_count": null,
|
||||
"id": "a679a299-e338-42d3-b54e-443e834def72",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-03-15T00:40:07.365729Z",
|
||||
"iopub.status.busy": "2023-03-15T00:40:07.364694Z",
|
||||
"iopub.status.idle": "2023-03-15T00:40:07.505094Z",
|
||||
"shell.execute_reply": "2023-03-15T00:40:07.504364Z",
|
||||
"shell.execute_reply.started": "2023-03-15T00:40:07.365688Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"47 张静\n",
|
||||
"58 张静\n",
|
||||
"109 王涛\n",
|
||||
"209 王锐\n",
|
||||
"228 王锐\n",
|
||||
"273 王楠\n",
|
||||
"378 郭强\n",
|
||||
"408 王涛\n",
|
||||
"433 王楠\n",
|
||||
"465 郭强\n",
|
||||
"494 王永涛\n",
|
||||
"495 杨靖\n",
|
||||
"496 李晓宝\n",
|
||||
"497 王婧\n",
|
||||
"498 徐滨\n",
|
||||
"499 孙华宇\n",
|
||||
"500 贾建慧\n",
|
||||
"501 郝国政\n",
|
||||
"502 崔双双\n",
|
||||
"503 赵振慧\n",
|
||||
"504 刘静远\n",
|
||||
"505 陆斌\n",
|
||||
"506 杜鹏\n",
|
||||
"507 赵亮亮\n",
|
||||
"508 张文秀\n",
|
||||
"ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"import math\n",
|
||||
@@ -910,6 +858,7 @@
|
||||
"#for k, v in dict2.items():\n",
|
||||
"# if 'email' not in v.keys():\n",
|
||||
"# print(k,v['name'],v['phone'])\n",
|
||||
"dict2[465]['email'] = '17240051@@ceic.com'\n",
|
||||
"filename = 'data/低碳院邮件信息.json'\n",
|
||||
"with open(filename, 'w') as fl:\n",
|
||||
" json.dump(dict2, fl, ensure_ascii=False)\n",
|
||||
@@ -919,10 +868,384 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "621624d7-7e9e-4309-b6d1-a9dcfc5a888a",
|
||||
"id": "46e58c6c-de99-4ec9-8bd7-c7e39ba815d5",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"fl_name = 'data/低碳院邮件信息.json'\n",
|
||||
"with open(fl_name,'r') as fl:\n",
|
||||
" dict2 = json.load(fl)\n",
|
||||
"dict2['465']['email'] = '20024422@ceic.com'\n",
|
||||
"filename = 'data/低碳院邮件信息.json'\n",
|
||||
"with open(filename, 'w') as fl:\n",
|
||||
" json.dump(dict2, fl, ensure_ascii=False)\n",
|
||||
"print('ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "6350fa35-d539-4719-bc0d-c80db500cc4b",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 导出2023年人员信息"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "2ddc6339-e5c6-4e56-a4d3-885ce7974aec",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import pymysql\n",
|
||||
"\n",
|
||||
"chongming = ['王锐','王楠','郭强','王涛','张静']\n",
|
||||
"dict1 = {}\n",
|
||||
"dict2 = {}\n",
|
||||
"dict3 = {}\n",
|
||||
"fl_name = 'data/低碳院邮件信息.json'\n",
|
||||
"with open(fl_name,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"for k, v in dict1.items():\n",
|
||||
" if v['name'] not in chongming and 'email' in v.keys():\n",
|
||||
" dict3[v['name']] = {'phone':v['phone'],'email':v['email']}\n",
|
||||
"db = pymysql.connect(host = \"localhost\",user = \"songyi\",password = \"yylzs\",database = \"ydyb\" )\n",
|
||||
"cursor = db.cursor()\n",
|
||||
"sql = \"SELECT a.name ,a.phone,b.avatar_id FROM people as a,places_people as b WHERE a.id =b.people_id AND b.place_id = 139\"\n",
|
||||
"cursor.execute(sql)\n",
|
||||
"results = cursor.fetchall()\n",
|
||||
"for result in results:\n",
|
||||
" bh = result[2]\n",
|
||||
" \n",
|
||||
" name = str(result[0]).strip()\n",
|
||||
"\n",
|
||||
" dict2.setdefault(bh,{})\n",
|
||||
" dict2[bh]['name'] = name\n",
|
||||
" if name in dict3.keys():\n",
|
||||
" \n",
|
||||
" dict2[bh]['email'] = dict3[name]['email']\n",
|
||||
" if result[1] is not None:\n",
|
||||
" dict2[bh]['phone'] = str(result[1]).strip()\n",
|
||||
"dict2[465]['email'] = '17240051@@ceic.com'\n",
|
||||
"filename = 'data/低碳院人员信息2023.json'\n",
|
||||
"with open(filename, 'w') as fl:\n",
|
||||
" json.dump(dict2, fl, ensure_ascii=False)\n",
|
||||
"print('ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "646d095f-1669-4bc2-885e-c203d0347e72",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-03-21T12:04:00.443790Z",
|
||||
"iopub.status.busy": "2023-03-21T12:04:00.442938Z",
|
||||
"iopub.status.idle": "2023-03-21T12:04:00.448277Z",
|
||||
"shell.execute_reply": "2023-03-21T12:04:00.447030Z",
|
||||
"shell.execute_reply.started": "2023-03-21T12:04:00.443751Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
"### 统计2023年体测报告人员邮件信息"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "31a10956-3b8d-4b5e-895a-2a1da783b4fe",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import glob\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"filename = 'data/低碳院邮件信息.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"dict2 = {}\n",
|
||||
"fls = glob.glob('file/139/2023-03-08/*.pdf')\n",
|
||||
"for fi in fls:\n",
|
||||
" bh = os.path.basename(fi).split('.')[0]\n",
|
||||
" if bh in dict1.keys() and 'email' in dict1[bh].keys():\n",
|
||||
" #print(bh,dict1[bh]['name'],dict1[bh]['email'])\n",
|
||||
" #print(bh,dict1[bh]['name'])\n",
|
||||
" dict2.setdefault(bh,{})\n",
|
||||
" dict2[bh]['name'] = dict1[bh]['name']\n",
|
||||
" dict2[bh]['email'] = dict1[bh]['email']\n",
|
||||
" dict2[bh]['file'] = fi\n",
|
||||
"#print(len(dict2))\n",
|
||||
"filename = 'data/低碳院邮件列表.json'\n",
|
||||
"with open(filename, 'w') as fl:\n",
|
||||
" json.dump(dict2, fl, ensure_ascii=False)\n",
|
||||
"print('ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "f04de52b-e1ad-4bdf-8cee-7e99fafcff6c",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import glob\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"filename = 'data/低碳院邮件信息.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"dict2 = {}\n",
|
||||
"fls = glob.glob('file/139/2023-03-08/*.pdf')\n",
|
||||
"for fi in fls:\n",
|
||||
" bh = os.path.basename(fi).split('.')[0]\n",
|
||||
" if bh in dict1.keys() and 'email' not in dict1[bh].keys():\n",
|
||||
" #print(bh,dict1[bh]['name'],dict1[bh]['email'])\n",
|
||||
" print(bh,dict1[bh]['name'])\n",
|
||||
" "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "45c9cd7b-db12-4f60-b550-f9f3f550ba93",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-03-21T13:40:39.830416Z",
|
||||
"iopub.status.busy": "2023-03-21T13:40:39.829533Z",
|
||||
"iopub.status.idle": "2023-03-21T13:40:39.834469Z",
|
||||
"shell.execute_reply": "2023-03-21T13:40:39.833400Z",
|
||||
"shell.execute_reply.started": "2023-03-21T13:40:39.830377Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
"### 群发邮件"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "7773fb0a-6644-4c8e-8424-24ebb9f04844",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from email.mime.text import MIMEText\n",
|
||||
"from email.mime.multipart import MIMEMultipart\n",
|
||||
"from email.mime.application import MIMEApplication\n",
|
||||
"from email.header import Header\n",
|
||||
"import smtplib\n",
|
||||
"import requests\n",
|
||||
"import time\n",
|
||||
"import re\n",
|
||||
"import json\n",
|
||||
" \n",
|
||||
"\n",
|
||||
"filename = 'data/低碳院邮件列表.json'\n",
|
||||
"\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" m_xx = json.load(fl)\n",
|
||||
"for k, v in m_xx.items():\n",
|
||||
" m_bh = str(k).rjust(5,\"0\")\n",
|
||||
" fl_name = v['file']\n",
|
||||
" fl = f\"{m_bh}-{v['name']}.pdf\"\n",
|
||||
" m_rec = v['email']\n",
|
||||
" \n",
|
||||
" from_addr = 'kmingedu@163.com' #发件邮箱\n",
|
||||
" password = 'GKWUZXMVYKSSUSSL' #邮箱密码\n",
|
||||
" smtp_server = 'smtp.163.com' #SMTP服务器,以新浪为例\n",
|
||||
" server = smtplib.SMTP(smtp_server,25) #第二个参数为默认端口为25,有些邮件有特殊端口\n",
|
||||
" msg = MIMEMultipart()\n",
|
||||
" msg['Subject'] = Header(\"低碳清洁能源研究院体质监测报告(2023年3月)\",'utf-8')\n",
|
||||
" msg['From'] = Header('北京坤铭体质监测评估中心')\n",
|
||||
" msg['To'] = Header(m_rec)\n",
|
||||
"\n",
|
||||
" from_addr = 'kmingedu@163.com' #发件邮箱\n",
|
||||
" password = 'GKWUZXMVYKSSUSSL' #邮箱密码\n",
|
||||
" to_addr = m_rec #收件邮箱\n",
|
||||
" att1 =MIMEApplication(open(fl_name, 'rb').read())\n",
|
||||
" #att1[\"Content-Type\"] = 'application/octet-stream'\n",
|
||||
" # 这里的filename可以任意写,写什么名字,邮件中显示什么名字\n",
|
||||
" att1.add_header('Content-Disposition','attachment',filename=fl)\n",
|
||||
" msg.attach(att1)\n",
|
||||
" try:\n",
|
||||
" server.login(from_addr,password) #登录邮箱\n",
|
||||
" server.sendmail(from_addr,to_addr,msg.as_string()) #将msg转化成string发出\n",
|
||||
" server.quit\n",
|
||||
" time.sleep(3)\n",
|
||||
" print(f'{fl}邮件发送成功!')\n",
|
||||
" except smtplib.SMTPException:\n",
|
||||
" print (\"Error: 无法发送邮件\")\n",
|
||||
" \n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "39575670-4a54-4374-8c26-4523b5782c78",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 统计2022年12月体测报告人员邮件信息"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 45,
|
||||
"id": "ec395435-7596-4de8-9f41-f45c0c744c3d",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-03-21T13:37:27.837531Z",
|
||||
"iopub.status.busy": "2023-03-21T13:37:27.836685Z",
|
||||
"iopub.status.idle": "2023-03-21T13:37:27.851993Z",
|
||||
"shell.execute_reply": "2023-03-21T13:37:27.850923Z",
|
||||
"shell.execute_reply.started": "2023-03-21T13:37:27.837490Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"106\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import glob\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"filename = 'data/低碳院邮件信息.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"dict2 = {}\n",
|
||||
"fls = glob.glob('file/139/2022-12-31/*.pdf')\n",
|
||||
"for fi in fls:\n",
|
||||
" bh = os.path.basename(fi).split('.')[0]\n",
|
||||
" if bh in dict1.keys() and 'email' in dict1[bh].keys():\n",
|
||||
" #print(bh,dict1[bh]['name'],dict1[bh]['email'])\n",
|
||||
" #print(bh,dict1[bh]['name'])\n",
|
||||
" dict2.setdefault(bh,{})\n",
|
||||
" dict2[bh]['name'] = dict1[bh]['name']\n",
|
||||
" dict2[bh]['email'] = dict1[bh]['email']\n",
|
||||
" dict2[bh]['file'] = fi\n",
|
||||
"#print(len(dict2))\n",
|
||||
"filename = 'data/低碳院邮件列表202212.json'\n",
|
||||
"with open(filename, 'w') as fl:\n",
|
||||
" json.dump(dict2, fl, ensure_ascii=False)\n",
|
||||
"print('ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 44,
|
||||
"id": "977e29b0-2b3f-4941-b33a-0b3b5ac4aced",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-03-21T13:37:12.258067Z",
|
||||
"iopub.status.busy": "2023-03-21T13:37:12.257187Z",
|
||||
"iopub.status.idle": "2023-03-21T13:37:12.268960Z",
|
||||
"shell.execute_reply": "2023-03-21T13:37:12.267879Z",
|
||||
"shell.execute_reply.started": "2023-03-21T13:37:12.258026Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"497 王婧\n",
|
||||
"499 孙华宇\n",
|
||||
"502 崔双双\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import glob\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"filename = 'data/低碳院邮件信息.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"dict2 = {}\n",
|
||||
"fls = glob.glob('file/139/2022-12-31/*.pdf')\n",
|
||||
"for fi in fls:\n",
|
||||
" bh = os.path.basename(fi).split('.')[0]\n",
|
||||
" if bh in dict1.keys() and 'email' not in dict1[bh].keys():\n",
|
||||
" #print(bh,dict1[bh]['name'],dict1[bh]['email'])\n",
|
||||
" print(bh,dict1[bh]['name'])\n",
|
||||
" "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "e8d5cc48-a23d-44d9-9130-6902452d5d18",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
"source": [
|
||||
"from email.mime.text import MIMEText\n",
|
||||
"from email.mime.multipart import MIMEMultipart\n",
|
||||
"from email.mime.application import MIMEApplication\n",
|
||||
"from email.header import Header\n",
|
||||
"import smtplib\n",
|
||||
"import requests\n",
|
||||
"import time\n",
|
||||
"import re\n",
|
||||
"import json\n",
|
||||
" \n",
|
||||
"\n",
|
||||
"filename = 'data/低碳院邮件列表202212.json'\n",
|
||||
"\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" m_xx = json.load(fl)\n",
|
||||
"for k, v in m_xx.items():\n",
|
||||
" m_bh = str(k).rjust(5,\"0\")\n",
|
||||
" fl_name = v['file']\n",
|
||||
" fl = f\"{m_bh}-{v['name']}.pdf\"\n",
|
||||
" m_rec = v['email']\n",
|
||||
" \n",
|
||||
" from_addr = 'kmingedu@163.com' #发件邮箱\n",
|
||||
" password = 'GKWUZXMVYKSSUSSL' #邮箱密码\n",
|
||||
" smtp_server = 'smtp.163.com' #SMTP服务器,以新浪为例\n",
|
||||
" server = smtplib.SMTP(smtp_server,25) #第二个参数为默认端口为25,有些邮件有特殊端口\n",
|
||||
" msg = MIMEMultipart()\n",
|
||||
" msg['Subject'] = Header(\"低碳清洁能源研究院体质监测报告(2022年12月)\",'utf-8')\n",
|
||||
" msg['From'] = Header('北京坤铭体质监测评估中心')\n",
|
||||
" msg['To'] = Header(m_rec)\n",
|
||||
"\n",
|
||||
" from_addr = 'kmingedu@163.com' #发件邮箱\n",
|
||||
" password = 'GKWUZXMVYKSSUSSL' #邮箱密码\n",
|
||||
" to_addr = m_rec #收件邮箱\n",
|
||||
" att1 =MIMEApplication(open(fl_name, 'rb').read())\n",
|
||||
" #att1[\"Content-Type\"] = 'application/octet-stream'\n",
|
||||
" # 这里的filename可以任意写,写什么名字,邮件中显示什么名字\n",
|
||||
" att1.add_header('Content-Disposition','attachment',filename=fl)\n",
|
||||
" msg.attach(att1)\n",
|
||||
" try:\n",
|
||||
" server.login(from_addr,password) #登录邮箱\n",
|
||||
" server.sendmail(from_addr,to_addr,msg.as_string()) #将msg转化成string发出\n",
|
||||
" server.quit\n",
|
||||
" time.sleep(3)\n",
|
||||
" print(f'{fl}邮件发送成功!')\n",
|
||||
" except smtplib.SMTPException:\n",
|
||||
" print (\"Error: 无法发送邮件\")\n",
|
||||
" "
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
||||
Reference in new issue
Block a user