国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

備忘2

2021-10-23 18:02 作者:Power_Tea  | 我要投稿

#! /usr/bin/python3

# coding=utf-8

import os

import xlrd

import smtplib

import pandas as pd


file_path = input("請輸入需要發(fā)送的文件名稱【注意全稱包含文件名】格式為:(./文件名.xlsx):")

card_list = []



def show_menu():

? ? """顯示菜單"""

? ? print("*" * 50)

? ? print("")

? ? print("歡迎使用 【 自動發(fā)送系統(tǒng) 】 V 1.0")

? ? print("")

? ? print("選擇? 【1】? 顯示全部名單")

? ? print("選擇? 【2】? 發(fā)送到郵箱")

? ? print("")

? ? print("選擇? 【0】? 退出系統(tǒng)")

? ? print("")

? ? print("*" * 50)



def show_all():

? ? """

顯示所有人員信息

? ? :return: 把值返回給函數(shù)

? ? """

? ? print("=" * 50)

? ? print("顯示所有人員信息")

? ? if len(card_list) == 0:

? ? ? ? print("當前沒有任何人員信息記錄,請檢查是否添加發(fā)送表格!")

? ? ? ? return

? ? print("")

? ? # 打印分割線

? ? print("#" * 50)

? ? # 遍歷列表依次輸出字典信息

? ? # for card_dict in card_list:

? ? #? ? ?print(card_dict["value"])

? ? df = pd.read_excel(file_path)

? ? df = df.set_index('姓名')? #表示索引為'姓名'的值,即去掉默認索引(1,2,3...)

? ? print(df)

? ? # print("-----------------------前3行-------------------------")

? ? # print(df.head(3))? ?#? 顯示文件前幾行信息括號中可以加顯示行號參數(shù)

? ? # print("="*50)

? ? # print("-----------------------后3行-------------------------")

? ? # print(df.tail(3))? # 顯示末尾幾行數(shù)據(jù)可以加參數(shù)



def r_excel_cards():

? ? # 先打開一個文件

? ? wb = xlrd.open_workbook(file_path)

? ? # 獲取第一個表

? ? sheet1 = wb.sheet_by_index(0)


? ? # 總行數(shù)

? ? nrows = sheet1.nrows

? ? # 總列數(shù)

? ? ncols = sheet1.ncols

? ? # 后面就通過循環(huán)即可遍歷數(shù)據(jù)了

? ? # 取數(shù)據(jù)

? ? for i in range(ncols):

? ? ? ? for j in range(nrows):

? ? ? ? ? ? # cell_value方法取出第i行j列的數(shù)據(jù)

? ? ? ? ? ? value = sheet1.cell_value(j, i)

? ? ? ? ? ? card_dict = {"value": value, }

? ? ? ? ? ? card_list.append(card_dict)



def email_qq():

? ? from email.mime.text import MIMEText? # 郵件正文

? ? from email.header import Header? # 郵件頭


? ? # 加載Excel文件

? ? wb = xlrd.open_workbook(file_path)

? ? sheet = wb.sheet_by_index(0)


? ? user_name = input("請輸入您自己的郵箱號:")

? ? user_pass = input("請輸入郵箱密碼:")


? ? # 登錄郵箱

? ? smtp_obj = smtplib.SMTP()

? ? smtp_obj.connect("smtp.qq.com")

? ? smtp_obj.login(user_name + "@qq.com", user_pass)


? ? # 循環(huán)遍歷Excel


? ? count = 0

? ? table_col_html = '<thead>'? # 表頭

? ? for row in sheet:? # sheet.iter_rows(min_row=0)

? ? ? ? count += 1

? ? ? ? if count == 1:? # 第一行

? ? ? ? ? ? for col in row:

? ? ? ? ? ? ? ? table_col_html += f"<th>{col.value}</th>"

? ? ? ? ? ? table_col_html += "</thead>"

? ? ? ? ? ? # print(table_col_html)

? ? ? ? ? ? continue

? ? ? ? else:

? ? ? ? ? ? row_text = "<tr>"? # 開始一行

? ? ? ? ? ? for cell in row:

? ? ? ? ? ? ? ? row_text += f"<td>{cell.value}</td>"

? ? ? ? ? ? row_text += "</tr>"? # 結束一行

? ? ? ? ? ? name = row[1]

? ? ? ? ? ? staff_email = row[0].value

? ? ? ? ? ? # print(name.value, staff_email)


? ? ? ? mail_body_context = f'''

? ? ? ? ? ? <h3>{name.value}\t你好:</h3>

? ? ? ? ? ? <p>請查收您本月工資,如有疑問電話聯(lián)系</p>

? ? ? ? ? ? <table border="1px solid black">

? ? ? ? ? ? ?{table_col_html}

? ? ? ? ? ? {row_text}

? ? ? ? ? ?</table>


? ? ? ? '''


? ? ? ? msg_body = MIMEText(mail_body_context, "html", "utf-8")

? ? ? ? msg_body["From"] = Header("xxx公司人事部", "utf-8")? # 發(fā)送者

? ? ? ? msg_body["To"] = Header("xxx公司員工", "utf-8")? # 接受者

? ? ? ? msg_body["Subject"] = Header("xxx公司", "utf-8")? # 主題


? ? ? ? # 發(fā)郵件

? ? ? ? smtp_obj.sendmail(user_name + "@qq.com", [staff_email, ], msg_body.as_string())

? ? ? ? print(f"成功發(fā)送 {name.value} 到 {staff_email} 中.....")



while True:

? ? #? 顯示菜單

? ? show_menu()

? ? action_str = input("請選擇希望執(zhí)行的操作:")

? ? print("您選擇的操作是 【%s】" % action_str)

? ? if action_str in ["1", "2", "3"]:

? ? ? ? if action_str == "1":

? ? ? ? ? ? r_excel_cards()

? ? ? ? ? ? show_all()



? ? ? ? elif action_str == "2":

? ? ? ? ? ? email_qq()



? ? elif action_str == "0":


? ? ? ? print("歡迎再次使用 【 自動發(fā)送系統(tǒng) 】")

? ? ? ? # w_excel_cards()

? ? ? ? break


? ? else:

? ? ? ? print("您輸入的序號不正確請重新輸入!")


備忘2的評論 (共 條)

分享到微博請遵守國家法律
明溪县| 沅陵县| 嘉义县| 贵州省| 宝坻区| 无为县| 甘南县| 平遥县| 石景山区| 赞皇县| 阿尔山市| 五河县| 韩城市| 若尔盖县| 崇礼县| 横山县| 上林县| 西平县| 林西县| 特克斯县| 乐昌市| 延吉市| 昌江| 永州市| 宁城县| 平远县| 开鲁县| 垫江县| 阳城县| 龙川县| 稻城县| 兴化市| 双桥区| 大埔区| 孟津县| 兰州市| 仪陇县| 皋兰县| 改则县| 怀来县| 夏河县|