说明:
1、通过python面向对象htmltabl生成html表格。
2、然后将消息和文件发送到企业微信群
3、请注意面向对象的创建、传参、实例函数调用等。
4、请安装相关模块,以及在python3环境中执行
#! /usr/bin/python3
# -*- coding: utf-8 -*-
from HTMLTable import HTMLTable
import imgkit
import requests
import time
class Htmltabl:
def __init__(self, title, header_row, data_row):
self.title = title
self.header_row = header_row
self.data_row = data_row
def htmltabl(self):
# 标题内容
table = HTMLTable(caption=self.title)
# 表头内容
table.append_header_rows(
self.header_row,
)
# 添加数据
table.append_data_rows(
self.data_row,
)
# 设置标题样式
table.caption.set_style({
'color': '#871F78',
# 设置字体并加粗
'font-weight': 'bold',
'font-size': '30px',
})
# 设置表头样式
table.set_header_row_style({
'color': '#fff',
'background-color': '#48a6fb',
'font-weight': 'bold',
'font-size': '24px'</