欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python實(shí)現(xiàn)生成日?qǐng)?bào)的示例代碼

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

一:日?qǐng)?bào)生成工具

#!/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對(duì)比給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

二:日?qǐng)?bào)工具使用方式

生成html對(duì)象: html = GetHtml()

給html新增標(biāo)題: html.add_head(“標(biāo)題”)

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

total_table = list()
        total_header = ["日期", "進(jìn)件總量", "進(jìn)件完成量", "延時(shí)進(jìn)件量", "卡單量", "通過量", "拒絕量", "人工量",
                        "通過率(%)", "拒絕率(%)", "平均耗時(shí)(秒)"]
        # TODO: 查詢數(shù)據(jù)邏輯, 追加到total_table中
        if len(total_table) >= 2:
            # 通過率 拒絕率 平均耗時(shí) 增加高亮顯示
            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("表{}-{}授信機(jī)審".format(num, get_product_chinese_name(product_name)), total_header, total_table)

輸出html整個(gè)頁(yè)面:html.output_html()

三:最終日?qǐng)?bào)生成展示

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

相關(guān)文章

  • Pandas實(shí)現(xiàn)在線文件和剪貼板數(shù)據(jù)讀取詳解

    Pandas實(shí)現(xiàn)在線文件和剪貼板數(shù)據(jù)讀取詳解

    這篇文章主要為大家介紹的是Pandas兩種少用的讀取文件方式:讀取在線文件的數(shù)據(jù)和讀取剪貼板的數(shù)據(jù),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2022-06-06
  • python實(shí)現(xiàn)邏輯回歸的方法示例

    python實(shí)現(xiàn)邏輯回歸的方法示例

    這篇文章主要介紹了python實(shí)現(xiàn)邏輯回歸的方法示例,這是機(jī)器學(xué)習(xí)課程的一個(gè)實(shí)驗(yàn),整理出來共享給大家,需要的朋友可以參考學(xué)習(xí),下來要一起看看吧。
    2017-05-05
  • python處理變量交換與字符串及判斷的小妙招

    python處理變量交換與字符串及判斷的小妙招

    本文記錄一些 Python 日常編程中的小妙招,并使用 IPython 進(jìn)行交互測(cè)試,讓我們更好的了解和學(xué)習(xí) Python 的一些特性,對(duì)大家的學(xué)習(xí)或工作具有一定的價(jià)值,需要的朋友可以參考下
    2021-09-09
  • Python中pandas庫(kù)的常用操作實(shí)例

    Python中pandas庫(kù)的常用操作實(shí)例

    這篇文章主要介紹了Python中pandas庫(kù)的常用操作實(shí)例,Pandas 庫(kù)是一個(gè)免費(fèi)、開源的第三方 Python 庫(kù),是 Python 數(shù)據(jù)分析必不可少的工具之一,它為 Python 數(shù)據(jù)分析提供了高性能,且易于使用的數(shù)據(jù)結(jié)構(gòu),即 Series 和 DataFrame,需要的朋友可以參考下
    2023-07-07
  • 18個(gè)好用的Python技巧分享(建議收藏)

    18個(gè)好用的Python技巧分享(建議收藏)

    在這篇文章中,我們將討論最常用的一些python技巧,這些技巧都是在日常工作中使用過的簡(jiǎn)單的Trick,小編覺得好東西就是要拿出來和大家一起分享噠
    2023-07-07
  • Python之time模塊的時(shí)間戳,時(shí)間字符串格式化與轉(zhuǎn)換方法(13位時(shí)間戳)

    Python之time模塊的時(shí)間戳,時(shí)間字符串格式化與轉(zhuǎn)換方法(13位時(shí)間戳)

    今天小編就為大家分享一篇Python之time模塊的時(shí)間戳,時(shí)間字符串格式化與轉(zhuǎn)換方法(13位時(shí)間戳),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2019-08-08
  • python3?requests中文亂碼之壓縮格式問題解析

    python3?requests中文亂碼之壓縮格式問題解析

    這篇文章主要介紹了python3?requests中文亂碼問題之壓縮格式問題,我們?cè)谂老x時(shí),經(jīng)常會(huì)遇見中文亂碼問題,之前都是編碼格式的問題,很少遇見由于壓縮格式造成的編碼混亂問題,特記錄下,需要的朋友可以參考下
    2022-08-08
  • python 模擬登陸163郵箱

    python 模擬登陸163郵箱

    這篇文章主要介紹了python 模擬登陸163郵箱的示例,幫助大家更好的理解和使用python,感興趣的朋友可以了解下
    2020-12-12
  • Python根據(jù)字典值對(duì)字典進(jìn)行排序的三種方法實(shí)例

    Python根據(jù)字典值對(duì)字典進(jìn)行排序的三種方法實(shí)例

    Python中的字典是無序類型,沒有自己的排序方法,下面這篇文章主要給大家介紹了關(guān)于Python根據(jù)字典值對(duì)字典進(jìn)行排序的三種方法,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-09-09
  • Django REST Swagger實(shí)現(xiàn)指定api參數(shù)

    Django REST Swagger實(shí)現(xiàn)指定api參數(shù)

    這篇文章主要介紹了Django REST Swagger實(shí)現(xiàn)指定api參數(shù),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-07-07

最新評(píng)論