Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

a library for drawing the table in the terminal

Project Description

Printtable是一个可以在terminal上输出数据表样式的python公共库。

下载方式

 pip install printtable

引用printtable

 from printtable import PrintTable

首先我们需要构建表的表头,然后创建表

attributes=[[‘name’,’old’]]

table = PrintTable(attributes)

然后我们有两种方式向表内加入数据

1.append_data:可以通过明确特征来加入一行数据中的一部分数据或者多行数据。

 table.append_data(name=”Jack”,old = “20”)

 table.append_data(name =[“Jack”,”Mary”], old =[“20”,”19”])

2.append_data_list: 可以直接使用list格式的变量向表中加入一行数据。不过要注意数据的顺序要符合创建表时的表头相同。

 table.append_data_list([“Jack”,”20”])

支持加入中文数据,但表头目前只能支持英文。

 table.append_data(name = “小明”,old = “20”)

 table.append_data(name =[“小华”,”大傻”], old =[“20”,”19”])

 table.append_data_list([“二傻子”,”20”])

最后我们可以在terminal直接输出ASCII表。通过line_num参数来控制在每行数据前是否加上行号,1为加入,默认为不加入行号。

table.printTable(1)

table.printTable()

Release History

Release History

This version
History Node

1.2

History Node

1.0

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
printtable-1.2-py2.7.egg (6.5 kB) Copy SHA256 Checksum SHA256 2.7 Egg Nov 2, 2015
printtable-1.2.tar.gz (3.1 kB) Copy SHA256 Checksum SHA256 Source Nov 2, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting