使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第三方库


热门话题
java向嵌入式Jetty添加多个端点   java如何在JAXWS处理程序中区分请求和响应?   使用Scenebuilder for JAVAFx的登录应用程序的java MVC体系结构   java对话框将不显示   Windows 7上的Java系统变量   java删除动态添加的面板   java将Javadoc嵌入到HTML网站中   带有URL编码数据的java Spring RestTemplate POST请求   java JAXR只运行一次函数   HttpClient缺少java依赖项   java深层反射比较   基于javarmi和CORBA的分布式计算   如何使用当前数据库时间从Java更新MongoDB?   java通过光标保存数据调试时显示错误数据