当前位置: 首页 > news >正文

python生成日报

目录

    • 一:日报生成工具
    • 二:日报工具使用方式
    • 三:最终日报生成展示

一:日报生成工具

#!/usr/bin/python
# coding:utf8class GetHtml(object):def __init__(self):self._html_head = """<html><body style="background-color:#FAEBD7;">"""self._format_html_foot = """<p style="font-family: verdana,arial,sans-serif;font-size:10px;font-weight:lighter;">%s</p> """self._format_html_head = """<p style="font-family: verdana,arial,sans-serif;font-size:%dpx;font-weight:bold;align=center">%s</p> """self._html_tail = "</body></html>"self._html_p_head = """<p style="font-family: verdana,arial,sans-serif;font-size:12px;font-weight:bold;">%s</p> """self._table_caption = """ <caption style="caption-side:top;font-size:12px;font-weight:bold;">%s</caption> """self._table_head = """<table style="font-family: verdana,arial,sans-serif;font-size:11px;color:#000000;border-width: 1px;border-color: #222C44;border-collapse: collapse;" border="1"><tr> """self._format_table_th = """<th style="border-width: 1px;padding: 8px;border-style: solid;border-color: #98bf21;background-color: #A7C942;" nowrap>%s</th> """self._format_table_td = """<td style="border-width: 1px;padding: 8px;text-align: right;border-style: solid;border-color: #98bf21;background-color: #EAF2D3;" align="center" nowrap>%s</td> """self._table_tail = "</table>"self._content = ""self._table_html = []def add_table(self, table_title, th_info, td_info_list):table_str = ""table_p_head = self._html_p_head % (str(table_title))table_str = table_p_head + self._table_head# thtable_str += "<tr>"for th in th_info:temp_str = self._format_table_th % (str(th))table_str += temp_strtable_str += "</tr>"# tdfor td_info in td_info_list:table_str += "<tr>"for td in td_info:temp_str = self._format_table_td % (str(td))table_str += temp_strtable_str += "</tr>"table_str += self._table_tailself._table_html.append(table_str)def add_head(self, head, found_size=18):head_str = self._format_html_head % (found_size, str(head))self._table_html.append(head_str)def add_foot(self, foot):foot_str = self._format_html_foot % (str(foot))self._table_html.append(foot_str)@staticmethoddef concat_color(a, b):"""通过a,b对比给a增加高亮显示"""cmp_a, cmp_b = float(str(a).strip('%')), float(str(b).strip('%'))if cmp_a > cmp_b:new_a = '<font color="red">' + '{}↑'.format(a) + '</font>'elif cmp_a < cmp_b:new_a = '<font color="green">' + '{}↓'.format(a) + '</font>'else:new_a = areturn new_adef output_html(self):"""输出HTML文件"""html_content = self._html_headfor s in self._table_html:html_content += shtml_content += self._html_tailreturn html_content

二:日报工具使用方式

  • 生成html对象: html = GetHtml()
  • 给html新增标题: html.add_head(“标题”)
  • html种增加统计表格:
    total_table = list()total_header = ["日期", "进件总量", "进件完成量", "延时进件量", "卡单量", "通过量", "拒绝量", "人工量","通过率(%)", "拒绝率(%)", "平均耗时(秒)"]# TODO: 查询数据逻辑, 追加到total_table中if len(total_table) >= 2:# 通过率 拒绝率 平均耗时 增加高亮显示total_table[0][8] = html.concat_color(a=total_table[0][8], b=total_table[1][8])total_table[0][9] = html.concat_color(a=total_table[0][9], b=total_table[1][9])total_table[0][10] = html.concat_color(a=total_table[0][10], b=total_table[1][10])html.add_table("表{}-{}授信机审".format(num, get_product_chinese_name(product_name)), total_header, total_table)
    
  • 输出html整个页面:html.output_html()

三:最终日报生成展示

在这里插入图片描述

http://www.lryc.cn/news/94247.html

相关文章:

  • 【机器学习】——续上:卷积神经网络(CNN)与参数训练
  • 鲸鱼算法WOA优化VMD参数,最小包络熵、样本熵、信息熵、排列熵(适应度函数可自行选择,一键修改)包含MATLAB源代码...
  • ELK日志收集系统集群实验
  • 用Python写了一个下载网站所有内容的软件,可见即可下
  • gin使用embed打包html
  • Android启动优化实践
  • ROS:通信机制实操
  • C/C++内存管理(内存分布、动态内存分配、动态内存分配与释放、内存泄漏等)
  • 【云原生】软件架构的演进以及各个架构的优缺点
  • 力扣刷题笔记——二叉树
  • 【华为OD机试】工号不够用了怎么办?(python, java, c++, js)
  • 【leetcode】198. 打家劫舍
  • 【react全家桶学习】react的 (新/旧) 生命周期(重点)
  • Gradio私网和公网的使用
  • ant design vue 配置菜单外部打开
  • YOLOv5/v7 添加注意力机制,30多种模块分析⑦,CCN模块,GAMAttention模块
  • IDEA下Logback.xml自动提示功能配置
  • CUDA编程模型系列八(原子操作 / 规约 / 向量元素求和)
  • go语言系列基础教程总结(4)
  • 网络基础一:网络协议初识与网络传输基本流程
  • Mysql找出执行慢的SQL【慢查询日志使用与分析】
  • 设计模式3:单例模式:JMM与volatile和synchronized的关系
  • 一个简单的OPC UA/ModbusTCP 网关(Python)
  • 线性代数行列式的几何含义
  • python用flask将视频显示在网页上
  • 【数据挖掘】时间序列教程【一】
  • 优化索引粒度参数提升ClickHouse查询性能
  • selenium\webdriver\remote\errorhandler.py:242: SessionNotCreatedException问题解决
  • MySQL 备份与恢复
  • js中改变this指向的三种方式