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的更多相关文章

  1. Python打印表格

    使用Python在终端打印表格 import prettytable table = PrettyTable(['Title1', 'Title2', 'Title3']) table.add_row ...

  2. Python模块之"prettytable"

    Python模块之"prettytable" 摘要: Python通过prettytable模块可以将输出内容如表格方式整齐的输出.(对于用Python操作数据库会经常用到) 1. ...

  3. Python打印格式化与字符串

    关于Python打印格式化与字符串,比较全面的总结,希望对大家有帮助~ # -*- coding: cp936 -*- ''' 打印格式 ''' print "a" print & ...

  4. python打印表格式数据,留出正确的空格和段落星号或注释

    python打印表格式数据,留出正确的空格,格式化打出 代码如下: def printPicnic(itemsDict,leftWidth,rightWidth): print('PICNIC ITE ...

  5. Lodop打印表格带页头页尾 自动分页每页显示头尾

    Lodop中有两种专门给超文本表格的方式,ADD_PRINT_TABLE和ADD_PRINT_TBURL,该方式只能用于单个表格,表格外的内容不显示,是专门用于打印html超文本表格的.使用这两个语句 ...

  6. Lodop打印表格带页头页尾 高度是否包含页头页尾

    通过设置TableHeightScope,可以实现对ADD_PRINT_TABLE,表格带页头页尾,查看本博客另一篇博文:Lodop打印表格带页头页尾 自动分页每页显示头尾 超文本超过打印项高度,会自 ...

  7. python 打印 emoji

    python 打印 emoji 如需转发,请注明出处:小婷儿的python  https://www.cnblogs.com/xxtalhr/p/10486506.html 一.Unicode字符集: ...

  8. python打印列表的下标和值的例子:

    python打印列表的下标和值的例子: In [1]: list01=[1,4,5] In [10]: def funct01(ll):   ....:     for index,value in ...

  9. MVC打印表格,把表格内容放到部分视图打印

    假设在一个页面上有众多内容,而我们只想把该页面上的表格内容打印出来,window.print()方法会把整个页面的内容打印出来,如何做到只打印表格内容呢? 既然window.print()只会打印整页 ...

随机推荐

  1. mac mini纯键盘操作连接蓝牙鼠标

    许久不开家里的MAC MINI了,今天开来玩玩,结果进个桌面连接鼠标就费了好大的劲 现实情况: 1. 没有有线鼠标,只有一个USB键盘,一个微软3600蓝牙鼠标 MAC MINI连接上USB键盘,开机 ...

  2. 脚本加密http://www.datsi.fi.upm.es/~frosal/sources/

    shc的官网下载地址: http://www.datsi.fi.upm.es/~frosal/sources/ 安装: 复制代码 代码如下: tar xzvf shc-.tgz cd shc- mkd ...

  3. 【ZooKeeper】ZooKeeper入门流水记

    单机模式 下载zookeeper的包 wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.ta ...

  4. postman参数获取不到原因

    在使用postman时,会发现经常提示参数错误,然而代码没有问题,仔细一看,原来是粘贴复制参数到postman时,前后有空格.

  5. 图像处理滤波应用(Halcon)

    1.增强对比度:halcon算子 equ_histo_image (GrayImage, ImageEquHisto) 2.空间滤波基础 滤波指接受或拒绝一定的频率分量.低通滤波器的最终效果是模糊(平 ...

  6. Python3数字(Number)

    一.数学函数 二.随机数函数 三.三角函数 四.数学常量

  7. Linux Ubuntu 能PING IP但不能PING主机域名的解决方法

    ------------------------------------------------------------------------------- vi /etc/nsswitch.con ...

  8. python中,如何将字符串转换为数字(将数字转换为整型),字符串的10转换为整型的10,10.5转换为10

    说明: 在实际的应用过程中,有的时候可能会遇到字符串的10,需要将字符串的10转换为数字的10 在此记录下,通过int函数转换的过程. 操作过程: 1.将字符串转换为整型的10 >>> ...

  9. akka cluster singleton

    cluster singleton 需要注意的一点是 ClusterSingletonProxy 必须和 ClusterSingletonManager 一起工作 尝试过通过 path 来获得 sin ...

  10. Pro ASP.NET MVC –第三章 MVC模式

    在第七章,我们将创建一个更复杂的ASP.NET MVC示例,但在那之前,我们会深入ASP.NET MVC框架的细节:我们希望你能熟悉MVC设计模式,并且考虑为什么这样设计.在本章,我们将讨论下列内容 ...