使pandas数据框看起来更漂亮

pretty-html-table的Python项目详细描述


pretty_html_table-使漂亮的html表格变得简单

详细的使用文档仍在进行中 这个包的目标是将pandas数据框架转换成一个漂亮的html表。 截至目前,有10种颜色可供选择。这个包与其他用来发送电子邮件的包嵌入得非常好。 格式被设置为行项目,这样每个电子邮件提供者都可以理解它(而不是使用css样式)。

这是您可以在计算机上安装它的方法:

pip install pretty_html_table

例如,这就是如何转换数据帧:

import pretty_html_table
html_table_blue_light = build_table(pd.read_excel('df.xlsx'), 'blue_light')
print(html_table_blue_light)

为什么选择漂亮的HTML表?

它与其他用于发送电子邮件的python包集成得非常好。只需将此包的结果添加到电子邮件的正文中,然后瞧。

可用颜色列表

Namefont styleHeaderRows
'blue_light'Century GothicBold: yes / Background color: white / Font color: dark blueOdd background color: light blue / Even background color: white
blue_dark'Century GothicBold: yes / Background color: dark blue / Font color: whiteOdd background color: light blue / Even background color: white
grey_light'Century GothicBold: yes / Background color: white / Font color: dark greyOdd background color: light grey / Even background color: white
grey_dark'Century GothicBold: yes / Background color: dark grey / Font color: whiteOdd background color: light grey / Even background color: white
orange_light'Century GothicBold: yes / Background color: white / Font color: dark orangeOdd background color: light orange / Even background color: white
orange_dark'Century GothicBold: yes / Background color: dark orange / Font color: whiteOdd background color: light orange / Even background color: white
yellow_light'Century GothicBold: yes / Background color: white / Font color: dark yellowOdd background color: light yellow / Even background color: white
yellow_dark'Century GothicBold: yes / Background color: dark yellow / Font color: whiteOdd background color: light yellow / Even background color: white
green_light'Century GothicBold: yes / Background color: white / Font color: dark greenOdd background color: light green / Even background color: white
green_dark'Century GothicBold: yes / Background color: dark green / Font color: whiteOdd background color: light green / Even background color: white

与o365包集成的示例

O365

首先,我们创建一个发送电子邮件的函数:

import O365
from O365 import Account

credentials = (o365credid, o365credpwd)
account = Account(credentials)

def send_email(account, to, subject, start, body, end):
    m = account.new_message()
    m.to.add(to)
    m.subject = subject
    m.body = start + body + end
    m.send()

然后我们可以使用HTML语言编写电子邮件的开头和结尾:

start = """<html>
                <body>
                    <strong>There should be an table here:</strong></br>"""


end = """</body>
    </html>
    """

最后,我们可以使用漂亮的HTML包发送电子邮件:

import ph_table

html_table_blue_light = build_table(pd.read_excel('df.xlsx'), 'blue_light')

send_email(account
           , 'test@any.com'
           , 'test table'
           , start
           , html_table_blue_light
           , end)

以下是所有当前可用的颜色:

LightDark

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
trycatch块中的java,是否“最终”覆盖异常块中的“返回”?   java在无限循环运行时,不明白为什么   导入javax时发生java错误。jnlp库   java Android:通过编程方式从微调器创建ArrayList   java Apache camel在处理所有文件后创建空ctl文件   运行外部文件Java   批处理文件Java关于运行时的混淆。memory()与Windows的物理内存使用历史记录图   java Play Framework 2/冗余对象验证   java如何纠正“注入目标不能声明为静态的”警告   java使用“this::content”或“::content”不按预期工作,包含来自同一thymeleaf模板的片段   无法使用Java和Apache POI写入Excel文件   java仅使用Twitter4j搜索带有图片/媒体的推文   java Hibernate惰性加载在@OneToOne映射中不起作用   java从外部存储器读取数据库文件   java从引用bean的映射中获取键值   java Springboot应用在实现MongoRepository时无法运行   java从2d数组返回多个匹配项   java文件>字节[]>字符串>字节[]>文件转换   JavaFX按钮释放事件