rpm包:

  1. [root@D129 cli]# yum info python-prettytable
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. * epel: mirrors.huaweicloud.com
  5. * extras: mirrors.cn99.com
  6. * updates: mirrors.cn99.com
  7. Available Packages
  8. Name : python-prettytable
  9. Arch : noarch
  10. Version : 0.7.
  11. Release : .el7
  12. Size : k
  13. Repo : base//x86_64
  14. Summary : Python library to display tabular data in tables
  15. URL : http://pypi.python.org/pypi/PrettyTable
  16. License : BSD
  17. Description : PrettyTable is a simple Python library designed to make it quick and easy to
  18. : represent tabular data in visually appealing ASCII tables. It was inspired by
  19. : the ASCII tables used in the PostgreSQL shell psql. PrettyTable allows for
  20. : selection of which columns are to be printed, independent alignment of columns
  21. : (left or right justified or centred) and printing of "sub-tables" by specifying
  22. : a row range.
  23.  
  24. [root@D129 cli]#

官网:

https://code.google.com/archive/p/prettytable/

文档:

https://code.google.com/archive/p/prettytable/wikis/Tutorial.wiki

小例子:

  1. from prettytable import PrettyTable
  2.  
  3. ... ...
  4.  
  5. x = PrettyTable(["port", "rx_pps", "rx_bps", "rx_drops", "rx_errors", "tx_pps", "tx_bps", "tx_drops", "tx_errors"])
  6. x.align["port"] = "l"
    ... ...
  7. for i in range(length):
  8. x.add_row([new_item.port, rpps, rbps, rx_drop, rx_errs, tpps, tbps, tx_drop, tx_errs])
  9. sys.stderr.write(str(x) + "\n")
  10. ... ...

输出:

  1. [root@A04-R08-I244-12-9283C72 tong]# ./ovs-stat.py 1>/dev/null
  2. +-----------------+--------+--------+----------+-----------+--------+--------+----------+-----------+
  3. | port | rx_pps | rx_bps | rx_drops | rx_errors | tx_pps | tx_bps | tx_drops | tx_errors |
  4. +-----------------+--------+--------+----------+-----------+--------+--------+----------+-----------+
  5. | dpdk0 | 0.0 | 0.0 | 0 | 0 | 0.0 | 0.0 | 0 | 0 |
  6. | port-uzwlar0rxo | 0.0 | 0.0 | 0 | 0 | 0.0 | 0.0 | 0 | 0 |
  7. | vx10.0.57.13 | 0.0 | 0.0 | 0 | 0 | 0.0 | 0.0 | 0 | 0 |
  8. | vx10.0.54.235 | 0.0 | 0.0 | 0 | 0 | 0.0 | 0.0 | 0 | 0 |
  9. +-----------------+--------+--------+----------+-----------+--------+--------+----------+-----------+
  10. +-----------------+---------------+--------------+----------+-----------+---------------+--------------+----------+-----------+
  11. | port | rx_pps | rx_bps | rx_drops | rx_errors | tx_pps | tx_bps | tx_drops | tx_errors |
  12. +-----------------+---------------+--------------+----------+-----------+---------------+--------------+----------+-----------+
  13. | dpdk0 | 1.54353919126 | 180.20820058 | 0 | 0 | 1.54353919126 | 183.68116376 | 0 | 0 |
  14. | port-uzwlar0rxo | 0.0 | 0.0 | 0 | 0 | 0.0 | 0.0 | 0 | 0 |
  15. | vx10.0.57.13 | 0.0 | 0.0 | 0 | 0 | 0.0 | 0.0 | 0 | 0 |
  16. | vx10.0.54.235 | 0.0 | 0.0 | 0 | 0 | 0.0 | 0.0 | 0 | 0 |
  17. +-----------------+---------------+--------------+----------+-----------+---------------+--------------+----------+-----------+

[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. install ceph by ceph-deploy

    使用阿里云源安装ceph Luminous https://liuxu.co/2017/09/19/install-ceph-Luminous-on-centos7-with-ceph-deploy/ ...

  2. maven的配置及一些常用命令

    一般来说,github上大多的java项目都是使用maven,ant等进行构建的.由于之前没有使用过maven,因此这几天对maven进行了简单的学习.古话说:“温故而知新”,一些命令长时间不使用都会 ...

  3. Java知多少(97)绘图模式概述

    绘图模式是指后绘制的图形与早先绘制的图形有重叠时,如何确定重叠部分的颜色.例如,后绘制的覆盖早先绘制的:或者后绘制与早先绘制的两种颜色按某种规则混合.主要有正常模式和异或模式两种:正常模式是后绘制的图 ...

  4. Springboot学习笔记(六)-配置化注入

    前言 前面写过一个Springboot学习笔记(一)-线程池的简化及使用,发现有个缺陷,打个比方,我这个线程池写在一个公用服务中,各项参数都定死了,现在有两个服务要调用它,一个服务的线程数通常很多,而 ...

  5. SQL中in参数在存储过程中传递及使用的方法

    背景: 1.使用存储过程 2.存储过程中有in 3.in括号里面的内容作为参数传递 解决方案: 1.直接拼接sql 可在存储过程中拼接字符串,然后执行此字符串,类似于js中的eval PROCEDUR ...

  6. mysql wait_timeout 8小时问题解决,tomcat数据源的配置

    异常报错: 2017-02-13 09:30:17.597 [startQuertz_Worker-6] ERROR com.autoyol.task.TransStatManageTask#exec ...

  7. IOC容器特性注入第三篇:Attribute封装

    Attribute(特性)=>就是对类,方法,字段的自定义属性的基类.可以利用Attribute对类,方法等进行自定义描述,方便区分. 既然如此,那我们就可以那些需要注入IOC容器和不需要注入I ...

  8. [JS] ECMAScript 6 - String, Number, Function : compare with c#

    字符串的扩展 正则的扩展 数值的扩展 函数的扩展 字符串的扩展 js 字符的 Unicode 表示法 codePointAt() String.fromCodePoint() 字符串的遍历器接口 at ...

  9. 如何在Ubuntu 16.04上安装配置Redis

    如何在Ubuntu 16.04上安装配置Redis Redis是一个内存中的键值存储,以其灵活性,性能和广泛的语言支持而闻名.在本指南中,我们将演示如何在Ubuntu 16.04服务器上安装和配置Re ...

  10. win7 cmd终端连接android手机运行adb shell脚本命令

    win7 cmd终端连接android手机运行adb shell脚本命令 (2013-03-22 20:13:57) 转载▼ 标签: android it shell 连接 linux 分类: 嵌入式 ...