print_formats.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:infrared 作者: redhat-openstack 项目源码 文件源码
def fancy_table(table_headers, *table_rows):
    """Creates a fancy table string from the given data

    :param table_headers: Iterable contains the table's headers
    :param table_rows: Iterable elements contain the table rows (body)
    :return: Formatted string represents the newly created table
    """
    # coloring class degrates gracefully if output is redirected so we will
    # not endup with ANSI escapes if we redirect console.
    table_data = [[c for c in table_headers]]
    table_data.extend(table_rows)

    table = AsciiTable(table_data=table_data)
    table.inner_row_border = True

    return table.table
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号