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()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file printtable-1.2.tar.gz.
File metadata
- Download URL: printtable-1.2.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56ea5bcfde531aa13e9ec083b23446f944e2326182931990e9a6e41fcbdbd21d
|
|
| MD5 |
a0c56bf262cd1429f78888e51caa1aa3
|
|
| BLAKE2b-256 |
26a8cfdbd4a1c9e7a8229d21298f31cf156a4d8d2f0925648d13c1fc6957fa67
|
File details
Details for the file printtable-1.2-py2.7.egg.
File metadata
- Download URL: printtable-1.2-py2.7.egg
- Upload date:
- Size: 6.5 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a6117fb32758c3fc8f7436a45edc5abb208af4e720bbca068745eecd2de58b9
|
|
| MD5 |
bff09154dce0cbd7c7ec2c83e8cb41cf
|
|
| BLAKE2b-256 |
c1964c7f869387185ce515aa92da74a9fe8fcf8531a0456da99650d9b348a891
|