最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python生成日報全過程

 更新時間:2025年12月31日 08:46:24   作者:StanwenRen  
文章介紹了日報生成工具的使用方式,包括生成HTML對象、新增標題和統(tǒng)計表格、輸出整個頁面等步驟,最終展示日報

python生成日報

一:日報生成工具

#!/usr/bin/python
# coding:utf8

class 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
        # th
        table_str += "<tr>"
        for th in th_info:
            temp_str = self._format_table_th % (str(th))
            table_str += temp_str
        table_str += "</tr>"
        # td
        for 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_str
            table_str += "</tr>"
        table_str += self._table_tail
        self._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)

    @staticmethod
    def 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 = a
        return new_a

    def output_html(self):
        """輸出HTML文件"""
        html_content = self._html_head
        for s in self._table_html:
            html_content += s
        html_content += self._html_tail
        return html_content


二:日報工具使用方式

  • 生成html對象: html = GetHtml()
  • 給html新增標題: html.add_head(“標題”)

html種增加統(tǒng)計表格:

total_table = list()
        total_header = ["日期", "進件總量", "進件完成量", "延時進件量", "卡單量", "通過量", "拒絕量", "人工量",
                        "通過率(%)", "拒絕率(%)", "平均耗時(秒)"]

        # TODO: 查詢數(shù)據(jù)邏輯, 追加到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()

三:最終日報生成展示

總結(jié)

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • python代碼區(qū)分大小寫嗎

    python代碼區(qū)分大小寫嗎

    在本篇文章里小編給大家整理了一篇關(guān)于python是否區(qū)分大小寫的相關(guān)內(nèi)容,對此有疑惑的新手們來學習下吧。
    2020-06-06
  • Python實現(xiàn)冒泡排序算法的示例解析

    Python實現(xiàn)冒泡排序算法的示例解析

    冒泡排序(Bubble Sort)是一種簡單的排序算法。本文將詳細為大家講講Python實現(xiàn)冒泡排序算法的方法,感興趣的小伙伴可以跟隨小編一起學習一下
    2022-06-06
  • Pandas中統(tǒng)計匯總函數(shù)dt.is_month_end()的使用

    Pandas中統(tǒng)計匯總函數(shù)dt.is_month_end()的使用

    dt.is_month_end()函數(shù)是Pandas中一個非常實用的統(tǒng)計匯總函數(shù),它能夠幫助我們快速識別時間序列數(shù)據(jù)中每個月的最后一天,下面就來介紹一下如何使用,感興趣的可以了解一下
    2025-05-05
  • 在python 3.14 容器中安裝和使用chdb包

    在python 3.14 容器中安裝和使用chdb包

    文章介紹了如何在Python容器中使用chdb包進行ClickHouse數(shù)據(jù)庫的查詢,本文給大家講解的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友參考下吧
    2026-02-02
  • python使用jenkins發(fā)送企業(yè)微信通知的實現(xiàn)

    python使用jenkins發(fā)送企業(yè)微信通知的實現(xiàn)

    公司使用的是企業(yè)微信,因此考慮Jenkins通知企業(yè)微信機器人的實現(xiàn)方式,本文主要介紹了python使用jenkins發(fā)送企業(yè)微信通知的實現(xiàn),感興趣的可以了解一下
    2021-06-06
  • python 自動監(jiān)控最新郵件并讀取的操作

    python 自動監(jiān)控最新郵件并讀取的操作

    這篇文章主要介紹了python 自動監(jiān)控最新郵件并讀取的操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2021-03-03
  • 淺析Python模塊之間的相互引用問題

    淺析Python模塊之間的相互引用問題

    這篇文章主要介紹了Python模塊之間的相互引用問題,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-02-02
  • Python利用shutil模塊實現(xiàn)文件的裁剪與壓縮

    Python利用shutil模塊實現(xiàn)文件的裁剪與壓縮

    shutil可以簡單地理解為sh+util ,shell工具的意思。shutil模塊是對os模塊的補充,主要針對文件的拷貝、刪除、移動、壓縮和解壓操作。本文將利用這一模塊實現(xiàn)文件的裁剪、壓縮與解壓縮,需要的可以參考一下
    2022-05-05
  • pytorch如何對image和label同時進行隨機翻轉(zhuǎn)

    pytorch如何對image和label同時進行隨機翻轉(zhuǎn)

    這篇文章主要介紹了pytorch如何對image和label同時進行隨機翻轉(zhuǎn)問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-09-09
  • Python爬取數(shù)據(jù)并寫入MySQL數(shù)據(jù)庫的實例

    Python爬取數(shù)據(jù)并寫入MySQL數(shù)據(jù)庫的實例

    今天小編就為大家分享一篇Python爬取數(shù)據(jù)并寫入MySQL數(shù)據(jù)庫的實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-06-06

最新評論

上高县| 永昌县| 鄄城县| 呼和浩特市| 会泽县| 乌拉特中旗| 罗城| 义乌市| 济源市| 云浮市| 潜江市| 公安县| 金乡县| 鄢陵县| 滕州市| 桂东县| 常山县| 泰兴市| 天台县| 七台河市| 安福县| 白城市| 土默特右旗| 丽水市| 孟津县| 宜章县| 万荣县| 楚雄市| 东兰县| 长乐市| 阳泉市| 高要市| 商都县| 仪陇县| 天镇县| 茂名市| 旅游| 拉萨市| 闸北区| 昭觉县| 喀喇沁旗|