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

Python實現(xiàn)生成日報的示例代碼

 更新時間:2023年06月19日 16:38:45   作者:一夜奈何梁山  
這篇文章主要為大家詳細介紹了如何利用Python實現(xiàn)生成日報的功能,文中的示例代碼講解詳細,感興趣的小伙伴可以跟隨小編一起學習一下

一:日報生成工具

#!/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()

三:最終日報生成展示

到此這篇關于Python實現(xiàn)生成日報的示例代碼的文章就介紹到這了,更多相關Python生成日報內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • python 等差數(shù)列末項計算方式

    python 等差數(shù)列末項計算方式

    這篇文章主要介紹了python 等差數(shù)列末項計算方式,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-05-05
  • Python文件監(jiān)聽工具pyinotify與watchdog實例

    Python文件監(jiān)聽工具pyinotify與watchdog實例

    今天小編就為大家分享一篇關于Python文件監(jiān)聽工具pyinotify與watchdog實例,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2018-10-10
  • Flask-Vue前后端分離的全過程講解

    Flask-Vue前后端分離的全過程講解

    這篇文章主要介紹了Flask-Vue前后端分離的全過程,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-07-07
  • PyQt5每天必學之日歷控件QCalendarWidget

    PyQt5每天必學之日歷控件QCalendarWidget

    這篇文章主要為大家詳細介紹了PyQt5每天必學之日歷控件QCalendarWidget,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-04-04
  • 詳解Python中的Cookie模塊使用

    詳解Python中的Cookie模塊使用

    這篇文章主要介紹了詳解Python中的Cookie模塊使用,是Python入門學習中的基礎知識,需要的朋友可以參考下
    2015-07-07
  • 通過示例學習python中os模塊的使用

    通過示例學習python中os模塊的使用

    os模塊是Python中處理文件和文件夾的重要模塊,其中了解模塊的一些基本功能對于使用Python對excel進行數(shù)據(jù)分析具有很大的幫助,這篇文章主要介紹了python os模塊使用,感興趣的朋友跟隨小編一起看看吧
    2022-12-12
  • pip install -e.出現(xiàn)xxx module not found error的問題解決方案

    pip install -e.出現(xiàn)xxx module not fou

    這篇文章主要介紹了pip install -e.出現(xiàn)xxx module not found error的問題解決方案,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2025-07-07
  • 用python實現(xiàn)學生管理系統(tǒng)

    用python實現(xiàn)學生管理系統(tǒng)

    這篇文章主要為大家詳細介紹了用python實現(xiàn)學生管理系統(tǒng),文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-07-07
  • Django 過濾器匯總及自定義過濾器使用詳解

    Django 過濾器匯總及自定義過濾器使用詳解

    這篇文章主要介紹了Django 過濾器匯總及自定義過濾器使用詳解,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2019-07-07
  • Tensorflow2.4使用Tuner選擇模型最佳超參詳解

    Tensorflow2.4使用Tuner選擇模型最佳超參詳解

    這篇文章主要介紹了Tensorflow2.4使用Tuner選擇模型最佳超參詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-11-11

最新評論

靖西县| 定州市| 察哈| 长子县| 通山县| 沈阳市| 翁牛特旗| 梓潼县| 德江县| 仪征市| 澄城县| 嵊州市| 台湾省| 论坛| 甘德县| 宁安市| 黑山县| 广西| 湾仔区| 启东市| 瑞安市| 呼图壁县| 集贤县| 临高县| 刚察县| 师宗县| 松潘县| 隆回县| 丰镇市| 二手房| 郓城县| 饶河县| 文登市| 渭南市| 巨野县| 岳阳县| 特克斯县| 临猗县| 香港 | 云浮市| 清河县|