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. Linux安装R记要

    R在Linux上的安装有一些坑(Windows上安装会方便许多),在这里记录,希望可以减少读者不必要的麻烦.我的服务器是SUSE Linux 64位,无法接入互联网(安全原因,你懂的). 到R官网ht ...

  2. linux每日命令(36):wc命令

    Linux系统中的wc(Word Count)命令的功能为统计指定文件中的字节数.字数.行数,并将统计结果显示输出. 一.命令格式 wc [-clw][--help][--version][文件... ...

  3. pandas删除缺失数据(pd.dropna()方法)

    1.创建带有缺失值的数据库:   import pandas as pd import numpy as np df = pd.DataFrame(np.random.randn(5, 3), ind ...

  4. 【WPF】图片按钮的单击与双击事件

    需求:ListBox中的Item是按钮图片,要求单击和双击时触发不同的事件. XAML中需要引入System.Windows.Interactivity.dll xmlns:i="clr-n ...

  5. hdoj:2022

    #include <iostream> #include <string> using namespace std; int main() { int m, n; int x, ...

  6. ubuntu GCC 版本切换

    (1)  查看gcc以及g++的版本 gcc  -v g++ -v star@ai:~ $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_L ...

  7. Java 8 StampedLock解决同步问题

    Java 8新特性探究(十)StampedLock将是解决同步问题的新宠 JDK8中StampedLock原理探究 深入理解StampedLock及其实现原理 JDK1.8 StampedLock源码 ...

  8. Springboot学习笔记(三)-常用注入组件方式

    包扫描@ComponentScan+组件标注注解(@Controller.@Service.@Repository.@Component) 包扫描不是必须的,指定包名后以指定的包名为准,比如指定包名为 ...

  9. SSM框架搭建最新教程(超详细)

    个人认为使用框架并不是很难,关键要理解其思想,这对于我们提高编程水平很有帮助.不过,如果用都不会,谈思想就变成纸上谈兵了!!!先技术,再思想.实践出真知. 1.基本概念 1.1.Spring  Spr ...

  10. 前端和后端的数据交互(jquery ajax+python flask+mysql)

    上web课的时候老师布置的一个实验,要求省市连动,基本要求如下: 1.用select选中一个省份. 2.省份数据传送到服务器,服务器从数据库中搜索对应城市信息. 3.将城市信息返回客户,客户用sele ...