21 KiB
21 KiB
In [52]:
import openpyxl
import json
wb = openpyxl.load_workbook('data/农业银行测试名单.xlsx')
sheet = wb.active
# sheets = wb.sheetnames
person = {}
for n in range(2, sheet.max_row+1):
if sheet.cell(n,1).value is not None:
code = int(sheet.cell(n, 2).value)
person.setdefault(code, {})
dict1 = {}
dict1['name'] = sheet.cell(n, 3).value
if sheet.cell(n, 4).value ==1:
sex = '男'
else:
sex = '女'
dict1['sex'] = sex
birth = str(sheet.cell(n, 5).value).split()[0]
dict1['birth'] = birth
dict1['unit'] = sheet.cell(n, 1).value
if sheet.cell(n,10).value is not None:
dict1['phone'] = sheet.cell(n, 10).value
person[code] = dict1
filename = 'data/北京农行人员名单.json'
with open(filename, 'w') as fl:
json.dump(person, fl, ensure_ascii=False)
print('ok')ok
In [ ]:
import json
import time
import csv
filename = '../item.json'
item = {}
unit = {}
with open(filename,'r') as fl:
dict1 = json.load(fl)
for k,v in dict1.items():
item[k] = v
re_ta = {}
dict1 = {}
list1 = []
filename = 'data/北京农行人员名单.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
filename = 'data/places_result_20230521.csv'
with open(filename,'r',newline='') as csv_file:
fl = csv.reader(csv_file,delimiter=',')
header = next(fl)
for line in fl:
#line = re.sub('[\r\n\f ]{1,}', '', line)
list1.append(line)
#print(list1)
for result in list1:
user = str(result[2])
if user in dict1.keys():
m_item = str(result[3])
re_ta.setdefault(user,{})
re_ta[user]['name'] = dict1[user]['name']
re_ta[user]['sex'] = dict1[user]['sex']
re_ta[user]['unit'] = dict1[user]['unit']
item_name = item[m_item]['name']
re_ta[user].setdefault(item_name,{})
score = int(result[4])/item[m_item]['divisor']
re_ta[user][item_name]['成绩'] = f'{score} {item[m_item]["unit"]}'
print(len(re_ta))
filename = 'data/result_北京农行.json'
with open(filename,'w') as fl:
json.dump(re_ta, fl, ensure_ascii=False)
print(len(re_ta))In [ ]:
import json
import openpyxl
items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']
title = ['编号','姓名','性别','单位','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']
filename = 'data/result_北京农行.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
filename = 'data/北京农行人员名单.json'
with open(filename,'r') as fl:
dict2 = json.load(fl)
list1 = []
for k, v in dict1.items():
list2 = []
list2.append(str(k).rjust(5,'0'))
list2.append(v['name'])
list2.append(dict2[k]['sex'])
list2.append(dict2[k]['unit'])
for item in items:
if item in v.keys():
list2.append(v[item]['成绩'])
elif item =='name':
list2.append(v[item])
else:
list2.append('')
list1.append(list2)
filename = 'data/北京农行体测情况.xlsx'
wb = openpyxl.Workbook()
sheet = wb.active
sheet.append(title)
for row in list1:
sheet.append(row)
wb.save(filename)In [ ]:
import os,sys,shutil
import json
import math
import glob
from pathlib import Path
fi_path = 'file/2023-05-23'
old = []
dict2 = {}
filename = 'data/result_北京农行.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
for k, v in dict1.items():
m_name = v['name']
m_depart = v['unit']
dict2[int(k)] = [m_name,m_depart]
fls = glob.glob(f'{fi_path}/*.pdf')
for fn in fls:
old.append(os.path.basename(fn).split('.')[0])
for n in old:
o_name = f'{fi_path}/{n}.pdf'
new_path = Path(fi_path,'new',dict1[n]['unit'])
new_path.mkdir(parents = True, exist_ok = True)
n_name = Path(new_path,f'{str(n).rjust(5,"0")}-{dict2[int(n)][0]}.pdf')
if not os.path.exists(n_name):
shutil.copyfile(o_name,n_name)
print(n_name)
print('ok')In [53]:
import json
import openpyxl
wb = openpyxl.load_workbook('data/农业银行测试手机号码统计表.xlsx')
sheet = wb.active
# sheets = wb.sheetnames
dict1 = {}
for n in range(2, sheet.max_row+1):
if sheet.cell(n,5).value is not None:
phone = str(sheet.cell(n, 5).value)
dict1.setdefault(phone,{})
code = str(sheet.cell(n, 2).value)
unit = sheet.cell(n, 1).value
name = sheet.cell(n, 3).value
sex = sheet.cell(n, 4).value
dict1[phone]['code'] = code
dict1[phone]['name'] = name
#dict1[phone]['unit'] = unit
#dict1[phone]['sex'] = sex
filename = 'data/农业银行测试手机号码.json'
with open(filename,'w') as fl:
json.dump(dict1, fl, ensure_ascii=False)
print(len(dict1))
163
In [54]:
import random
import json
code_list = []
for i in range(10): # 0~9
code_list.append(str(i))
list1 = []
#print(code_num)
i = 1
while i < 165:
code = random.sample(code_list,6) #随机取6位数
code_num = ''.join(code)
if code_num not in list1:
list1.append(code_num)
i +=1
print(len(list1))
print(list1)
i = 0
filename = 'data/农业银行测试手机号码.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
for k, v in dict1.items():
dict1[k]['yzm'] = list1[i]
i +=1
with open(filename,'w') as fl:
json.dump(dict1, fl, ensure_ascii=False) 164 ['659821', '079384', '876923', '387406', '694158', '563974', '628540', '281407', '798056', '274185', '705316', '571698', '693240', '650329', '481397', '610492', '250746', '619873', '675018', '619204', '984351', '279548', '027154', '856432', '296138', '290486', '218396', '973605', '269043', '653487', '528397', '031947', '370415', '872591', '018592', '251794', '718203', '869254', '408517', '071948', '536729', '259430', '867310', '285413', '805216', '405192', '630721', '386219', '504216', '418752', '402398', '231947', '850743', '901378', '394175', '431092', '157489', '961378', '305921', '620417', '352906', '629380', '417086', '086149', '804693', '342580', '310827', '637102', '128635', '346780', '325076', '643917', '710548', '046732', '762390', '350712', '368419', '342701', '245107', '087136', '023185', '759846', '346758', '514976', '570482', '781935', '210987', '340615', '075891', '810596', '430689', '920785', '815347', '917562', '295817', '765238', '058479', '674159', '567894', '109842', '851943', '703918', '073489', '403958', '578492', '798046', '502876', '943180', '498306', '835760', '726305', '490867', '709413', '275683', '256934', '721830', '973841', '729685', '021349', '265413', '321597', '064187', '136794', '708352', '710928', '657129', '962105', '905436', '513749', '257361', '420691', '941567', '839574', '906358', '218095', '364152', '562149', '109823', '560942', '293561', '194053', '509246', '026951', '243561', '093154', '654083', '519048', '459136', '914362', '605834', '508693', '823906', '349725', '572390', '541236', '419570', '513467', '724063', '164823', '890712', '529840', '641958', '678590', '648951']
In [55]:
filename = 'data/农业银行测试手机号码.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
dict2 = {}
for k, v in dict1.items():
dict2.setdefault(v['yzm'],{})
dict2[v['yzm']]['code'] = v['code']
dict2[v['yzm']]['name'] = v['name']
print(len(dict2))
filename = 'data/yzm.json'
with open(filename,'w') as fl:
json.dump(dict2, fl, ensure_ascii=False)
163
In [37]:
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.sms.v20210111 import sms_client, models
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
try:
secretId = "AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc"
secretKey = "51XVL1YxDKI6mJh8au6DDuTskS1RhwJX"
cred = credential.Credential(secretId, secretKey)
httpProfile = HttpProfile()
httpProfile.reqMethod = "POST" # post请求(默认为post请求)
httpProfile.reqTimeout = 30 # 请求超时时间,单位为秒(默认60秒)
httpProfile.endpoint = "sms.tencentcloudapi.com" # 指定接入地域域名(默认就近接入)
clientProfile = ClientProfile()
clientProfile.signMethod = "TC3-HMAC-SHA256" # 指定签名算法
clientProfile.language = "en-US"
clientProfile.httpProfile = httpProfile
client = sms_client.SmsClient(cred, "ap-guangzhou", clientProfile)
req = models.SendSmsRequest()
req.SmsSdkAppId = "1400140089"
req.SignName = "坤铭教育"
req.TemplateId = "1808914"
req.TemplateParamSet = ["1234"]
req.PhoneNumberSet = ["+8613793180751"]
req.SessionContext = ""
req.ExtendCode = ""
req.SenderId = ""
resp = client.SendSms(req)
print(resp.to_json_string(indent=2))
except TencentCloudSDKException as err:
print(err){
"SendStatusSet": [
{
"SerialNo": "2640:135690281916850099280618075",
"PhoneNumber": "+8613793180751",
"Fee": 1,
"SessionContext": "",
"Code": "Ok",
"Message": "send success",
"IsoCode": "CN"
}
],
"RequestId": "7601194b-56e4-45a8-9543-6fcc76ce16a6"
}
In [41]:
dict1 = json.loads(resp.to_json_string(indent=2))
print(dict1['SendStatusSet'][0]["Message"])send success
In [57]:
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.sms.v20210111 import sms_client, models
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
import json
filename = 'data/短信测试手机号码.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
for k, v in dict1.items():
phone = '+86'+str(k)
yzm = v['yzm']
try:
secretId = "AKID22rVyvSqbikXFFvav31ykc9YmqjN6KYc"
secretKey = "51XVL1YxDKI6mJh8au6DDuTskS1RhwJX"
cred = credential.Credential(secretId, secretKey)
httpProfile = HttpProfile()
httpProfile.reqMethod = "POST" # post请求(默认为post请求)
httpProfile.reqTimeout = 30 # 请求超时时间,单位为秒(默认60秒)
httpProfile.endpoint = "sms.tencentcloudapi.com" # 指定接入地域域名(默认就近接入)
clientProfile = ClientProfile()
clientProfile.signMethod = "TC3-HMAC-SHA256" # 指定签名算法
clientProfile.language = "en-US"
clientProfile.httpProfile = httpProfile
client = sms_client.SmsClient(cred, "ap-guangzhou", clientProfile)
req = models.SendSmsRequest()
req.SmsSdkAppId = "1400140089"
req.SignName = "坤铭教育"
req.TemplateId = "1808914"
req.TemplateParamSet = [yzm]
req.PhoneNumberSet = [phone]
req.SessionContext = ""
req.ExtendCode = ""
req.SenderId = ""
resp = client.SendSms(req)
dict2 = json.loads(resp.to_json_string(indent=2))
print(v['name'],dict2['SendStatusSet'][0]["Message"])
except TencentCloudSDKException as err:
print(v['name'],err)亓宇航 send success 李伟丽 send success 高松 send success 张树伟 send success
In [ ]: