python 发送带附件邮件到钉钉邮箱+邮件内容带有表格

import smtplib

import pandas as pd

# smtplib这个模块是管发邮件

from email.mime.text import MIMEText

# 构造邮件内容

from email.mime.multipart import MIMEMultipart

import re

 

import os

from bs4 import BeautifulSoup as bs

#获取测试报告中的结果

def get_result(files):

listRes = []

for i in range(len(files)):

htmls = open(files[i],'r',encoding="utf-8")

htmlcontent = htmls.read()

htmlcontent1 = bs(htmlcontent,'html.parser')

ts = htmlcontent1.table

strs = str(ts)

h = re.findall(r'<td colspan="2">(.*?)</td?', strs)

h1 = h[2]

 

h11 = h1.replace('(','').replace(')','').replace('/',' ').split(' ')

listRes.append(h11)

return listRes

#邮件内容中写入表格

def get_table(files):

content = get_result(files)

# 构建了一个能发附件的邮件对象

newdata = {'total': {'运营': content[0][0], 'M站': content[1][0], 'APP': content[2][0]},

'success': {'运营': content[0][1], 'M站': content[1][1], 'APP': content[2][1]},

'fail': {'运营': content[0][2], 'M站': content[1][2], 'APP': content[2][2]},

'err

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值