[python2] python 打印表格 prettytable
rpm包:
[root@D129 cli]# yum info python-prettytable
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* epel: mirrors.huaweicloud.com
* extras: mirrors.cn99.com
* updates: mirrors.cn99.com
Available Packages
Name : python-prettytable
Arch : noarch
Version : 0.7.
Release : .el7
Size : k
Repo : base//x86_64
Summary : Python library to display tabular data in tables
URL : http://pypi.python.org/pypi/PrettyTable
License : BSD
Description : PrettyTable is a simple Python library designed to make it quick and easy to
: represent tabular data in visually appealing ASCII tables. It was inspired by
: the ASCII tables used in the PostgreSQL shell psql. PrettyTable allows for
: selection of which columns are to be printed, independent alignment of columns
: (left or right justified or centred) and printing of "sub-tables" by specifying
: a row range. [root@D129 cli]#
官网:
https://code.google.com/archive/p/prettytable/
文档:
https://code.google.com/archive/p/prettytable/wikis/Tutorial.wiki
小例子:
from prettytable import PrettyTable ... ... x = PrettyTable(["port", "rx_pps", "rx_bps", "rx_drops", "rx_errors", "tx_pps", "tx_bps", "tx_drops", "tx_errors"])
x.align["port"] = "l"
... ...
for i in range(length):
x.add_row([new_item.port, rpps, rbps, rx_drop, rx_errs, tpps, tbps, tx_drop, tx_errs])
sys.stderr.write(str(x) + "\n")
... ...
输出:
[root@A04-R08-I244-12-9283C72 tong]# ./ovs-stat.py 1>/dev/null
+-----------------+--------+--------+----------+-----------+--------+--------+----------+-----------+
| port | rx_pps | rx_bps | rx_drops | rx_errors | tx_pps | tx_bps | tx_drops | tx_errors |
+-----------------+--------+--------+----------+-----------+--------+--------+----------+-----------+
| dpdk0 | 0.0 | 0.0 | 0 | 0 | 0.0 | 0.0 | 0 | 0 |
| port-uzwlar0rxo | 0.0 | 0.0 | 0 | 0 | 0.0 | 0.0 | 0 | 0 |
| vx10.0.57.13 | 0.0 | 0.0 | 0 | 0 | 0.0 | 0.0 | 0 | 0 |
| vx10.0.54.235 | 0.0 | 0.0 | 0 | 0 | 0.0 | 0.0 | 0 | 0 |
+-----------------+--------+--------+----------+-----------+--------+--------+----------+-----------+
+-----------------+---------------+--------------+----------+-----------+---------------+--------------+----------+-----------+
| port | rx_pps | rx_bps | rx_drops | rx_errors | tx_pps | tx_bps | tx_drops | tx_errors |
+-----------------+---------------+--------------+----------+-----------+---------------+--------------+----------+-----------+
| dpdk0 | 1.54353919126 | 180.20820058 | 0 | 0 | 1.54353919126 | 183.68116376 | 0 | 0 |
| port-uzwlar0rxo | 0.0 | 0.0 | 0 | 0 | 0.0 | 0.0 | 0 | 0 |
| vx10.0.57.13 | 0.0 | 0.0 | 0 | 0 | 0.0 | 0.0 | 0 | 0 |
| vx10.0.54.235 | 0.0 | 0.0 | 0 | 0 | 0.0 | 0.0 | 0 | 0 |
+-----------------+---------------+--------------+----------+-----------+---------------+--------------+----------+-----------+
[python2] python 打印表格 prettytable的更多相关文章
- Python打印表格
使用Python在终端打印表格 import prettytable table = PrettyTable(['Title1', 'Title2', 'Title3']) table.add_row ...
- Python模块之"prettytable"
Python模块之"prettytable" 摘要: Python通过prettytable模块可以将输出内容如表格方式整齐的输出.(对于用Python操作数据库会经常用到) 1. ...
- Python打印格式化与字符串
关于Python打印格式化与字符串,比较全面的总结,希望对大家有帮助~ # -*- coding: cp936 -*- ''' 打印格式 ''' print "a" print & ...
- python打印表格式数据,留出正确的空格和段落星号或注释
python打印表格式数据,留出正确的空格,格式化打出 代码如下: def printPicnic(itemsDict,leftWidth,rightWidth): print('PICNIC ITE ...
- Lodop打印表格带页头页尾 自动分页每页显示头尾
Lodop中有两种专门给超文本表格的方式,ADD_PRINT_TABLE和ADD_PRINT_TBURL,该方式只能用于单个表格,表格外的内容不显示,是专门用于打印html超文本表格的.使用这两个语句 ...
- Lodop打印表格带页头页尾 高度是否包含页头页尾
通过设置TableHeightScope,可以实现对ADD_PRINT_TABLE,表格带页头页尾,查看本博客另一篇博文:Lodop打印表格带页头页尾 自动分页每页显示头尾 超文本超过打印项高度,会自 ...
- python 打印 emoji
python 打印 emoji 如需转发,请注明出处:小婷儿的python https://www.cnblogs.com/xxtalhr/p/10486506.html 一.Unicode字符集: ...
- python打印列表的下标和值的例子:
python打印列表的下标和值的例子: In [1]: list01=[1,4,5] In [10]: def funct01(ll): ....: for index,value in ...
- MVC打印表格,把表格内容放到部分视图打印
假设在一个页面上有众多内容,而我们只想把该页面上的表格内容打印出来,window.print()方法会把整个页面的内容打印出来,如何做到只打印表格内容呢? 既然window.print()只会打印整页 ...
随机推荐
- jpush在有网的情况下6002
网络处理问题. https://www.jpush.cn/qa/?qa=2476/%E7%BD%91%E7%BB%9C%E6%AD%A3%E5%B8%B8%E7%9A%84%E6%83%85%E5%8 ...
- 【Ubuntu】PHP环境安装-phpstudy for linux版
安装: wget -c http://lamp.phpstudy.net/phpstudy.bin chmod +x phpstudy.bin #权限设置sudo ./phpstudy.bin ...
- 【九天教您南方cass 9.1】01 安装Cad和Cass9.1
同学们大家好,欢迎收看由老王测量上班记出品的cass9.1视频课程 今后会将cass的教程目录定期发布在测量空间中. 我是本节课主讲老师九天. [点击索取cass教程]5元立得 (给客服说暗号:“老王 ...
- 【30集iCore3_ADP出厂源代码(ARM部分)讲解视频】30-12底层驱动之液晶画点驱动
视频简介:该视频介绍iCore3应用开发平台中液晶驱动的方法. 源视频包下载地址:链接:http://pan.baidu.com/s/1qXQoOQo 密码:gvgo 银杏科技优酷视频发布区:http ...
- android评分条RatingBar自定义设置
RatingBar为评分条控件,默认效果为若干个绿色的星星,如果想将其换成其他自定义图片就要自定义它的style.首先是布局文件: 其中android:numStars="5"设置 ...
- Android异步处理系列文章四篇之四 AsyncTask的实现原理
Android异步处理一:使用Thread+Handler实现非UI线程更新UI界面Android异步处理二:使用AsyncTask异步更新UI界面Android异步处理三:Handler+Loope ...
- python实现微信接口——itchat模块
python实现微信接口——itchat模块 安装 sudo pip install itchat 登录 itchat.auto_login() 这种方法将会通过微信扫描二维码登录,但是这种登录的方 ...
- Bootstrap的Model源码详细注释 (转)
原文: http://my.oschina.net/haogrgr/blog/323079?p=1 /* =============================================== ...
- JVM的内存划分以及常用参数
JVM的主要划分为: 堆内存,虚拟机栈,方法区,程序计数器,本地方法栈 堆内存: 这部分区域是各个线程共享的,java的大部分对象都是储存在堆中. 1.堆在分配对象内存区域的时候可以分为两种,第一种叫 ...
- officewebapps 服务器部署问题
officewebapps 服务器部署问题 部署文档 http://technet.microsoft.com/zh-cn/library/jj219455 New-OfficeWebAppsFarm ...