1、查看系统是否已经安装prettytable模块

2、下载prettytable模块

登陆:https://pypi.python.org/pypi/PrettyTable

3、安装PrettyTable模块

  1. [root@opsedu ~]# wget https://pypi.python.org/packages/source/P/PrettyTable/prettytable-0.7.2.tar.gz
  2. [root@opsedu ~]# tar -zxvf prettytable-0.7.2.tar.gz
  3. [root@opsedu prettytable-0.7.2]# python setup.py build
  4. running build
  5. running build_py
  6. creating build
  7. creating build/lib
  8. copying prettytable.py -> build/lib
  9. [root@opsedu prettytable-0.7.2]# python setup.py install   # 安装prettytable
  10. running install
  11. running bdist_egg
  12. running egg_info
  13. writing prettytable.egg-info/PKG-INFO
  14. writing top-level names to prettytable.egg-info/top_level.txt
  15. writing dependency_links to prettytable.egg-info/dependency_links.txt
  16. reading manifest file 'prettytable.egg-info/SOURCES.txt'
  17. reading manifest template 'MANIFEST.in'
  18. writing manifest file 'prettytable.egg-info/SOURCES.txt'
  19. installing library code to build/bdist.linux-x86_64/egg
  20. running install_lib
  21. running build_py
  22. creating build/bdist.linux-x86_64
  23. creating build/bdist.linux-x86_64/egg
  24. copying build/lib/prettytable.py -> build/bdist.linux-x86_64/egg
  25. byte-compiling build/bdist.linux-x86_64/egg/prettytable.py to prettytable.pyc
  26. creating build/bdist.linux-x86_64/egg/EGG-INFO
  27. copying prettytable.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
  28. copying prettytable.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
  29. copying prettytable.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
  30. copying prettytable.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
  31. zip_safe flag not set; analyzing archive contents...
  32. creating dist
  33. creating 'dist/prettytable-0.7.2-py2.6.egg' and adding 'build/bdist.linux-x86_64/egg' to it
  34. removing 'build/bdist.linux-x86_64/egg' (and everything under it)
  35. Processing prettytable-0.7.2-py2.6.egg
  36. creating /usr/lib/python2.6/site-packages/prettytable-0.7.2-py2.6.egg
  37. Extracting prettytable-0.7.2-py2.6.egg to /usr/lib/python2.6/site-packages
  38. Adding prettytable 0.7.2 to easy-install.pth file
  39. Installed /usr/lib/python2.6/site-packages/prettytable-0.7.2-py2.6.egg
  40. Processing dependencies for prettytable==0.7.2
  41. Finished processing dependencies for prettytable==0.7.2

4、测试pretty模块

  1. >>> import tab
  2. >>> from prettytable import PrettyTable>>> row = PrettyTable()
  3. >>> row.field_names = ["Name", "Age","Country","City"]
  4. >>> row.add_row(['shaw','23','China','Shanghai'])
  5. >>> row.add_row(['charle','29','China','Xuzhou'])
  6. >>> row.add_row(['jack','32','United States','Washington'])
  7. >>> print row
  8. +--------+-----+---------------+------------+
  9. |  Name  | Age |    Country    |    City    |
  10. +--------+-----+---------------+------------+
  11. |  shaw  |  23 |     China     |  Shanghai  |
  12. | charle |  29 |     China     |   Xuzhou   |
  13. |  jack  |  32 | United States | Washington |
  14. +--------+-----+---------------+------------+

附件列表

prettytable模块(格式化打印内容)的更多相关文章

  1. Python3之PrettyTable模块

    一. 简介 Python通过prettytable模块将输出内容如表格方式整齐输出,python本身并不内置,需要独立安装该第三方库. 二. 安装 方式一:pip安装 >>> pip ...

  2. Python模块——PrettyTable 模块

    简介 PrettyTable 是python中的一个第三方库,可用来生成美观的ASCII格式的表格,十分实用. 安装 pip install prettytable 示例 从已有文件创建 CSV fr ...

  3. python prettytable模块

    简介 Python通过PrettyTable模块可以将输出内容如表格方式整齐地输出. 安装 pip install prettytable 1 示例 from prettytable import P ...

  4. Python之读取用户指令和格式化打印

    Python之读取用户指令和格式化打印 一.读取用户指令 当你的程序要接收用户输入的指令时,可以用input函数: name = input("请输入你的名字:") print(& ...

  5. console 中的格式化打印(占位符),和样式定义

    格式化打印 Gecko 9.0 (Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6) 首次发布对string substitutions的支持.你可以在传递给 ...

  6. C#程序调用CodeSoft预先设计好的标签模块实现打印功能

    if (this.tbSetLabel.Text.Trim() == "") { MessageBox.Show("请先 Enter 选择标签模板文件!", & ...

  7. 3515 如何调试AT指令、查看拨号模块的打印

    冯sir给了一个在设备运行的程序serial,运行起来后可以敲指令输入AT指令,具体步骤如下: 1.将serial文件从U盘拷贝到设备里,U盘在设备系统下的目录是/stm/udisk/0/,但是注意设 ...

  8. Java获取当前时间年月日、时间格式化打印、字符串转日期

    package com.sysc.simple; import java.text.ParseException; import java.text.SimpleDateFormat; import ...

  9. 如何修改int的打印内容——史上最难的JAVA面试题

    序 今天看到了一个比较特别的面试题,考察的是如何改变int的System.out.print的结果.题目如下: 下面的一句话"这是初级java实习生面试题"非常挑衅的激起了大家做题 ...

随机推荐

  1. java sundry tips

    1.关于Arrays 记得binarySearch方法返回的int 类型的数值的含义.    If the array contains multiple elements with the spec ...

  2. Jmeter聚合报告

    Label:请求的Name. #Samples:发出请求数量. Average:平均响应时间(单位:ms). Median:全部响应时间中位数,. 90%Line:90%用户的响应时间低于这个时间. ...

  3. stm32寄存器版学习笔记09 IIC

    I²C(Inter-Integrated Circuit)总线是一种两线式串行总线,用于连接微控制器及其外设,是由数据线SDA和时钟SCL构成的串行总线,可发送和接收数据. IIC总线在传送数据过程中 ...

  4. Codeforces 559C Gerald and Giant Chess【组合数学】【DP】

    LINK 题目大意 有一个wxh的网格,上面有n个黑点,问你从(1,1)走到(w,h)不经过任何黑点的方案数 思路 考虑容斥 先把所有黑点按照x值进行排序方便计算 \(dp_{i}\)表示从起点走到第 ...

  5. Lua table

    获取数组长度 在Lua中可以使用“#”和table.maxn两种方法来获取数组的长度 arr = {,,,} arr[] = 7 都仅统计数字key的长度: #是从1递增到nil的长度: table. ...

  6. POJ3045 Cow Acrobats

    题意 Farmer John's N (1 <= N <= 50,000) cows (numbered 1..N) are planning to run away and join t ...

  7. 系列文章--一步一步学Silverlight2

    概述 由TerryLee编写的<Silverlight 2完美征程>一书,已经上市,在该系列文章的基础上补充了大量的内容,敬请关注.官方网站:http://www.dotneteye.cn ...

  8. FastAdmin 前端页面传参笔记

    FastAdmin 前端页面传参笔记 看到 QQ 群里的小伙伴询问如何传参,然后在社区里找到一笔记帖子 1 还要参考在线文档控制器部分2. 引用 Karson 的回复: 如果我们需要自己在控制器中透传 ...

  9. 记一笔vue中的中央事件总线的问题,以及解决方案

    代码结构:首先HeaderNav组件是被单独拎出来的,router-view中就对应了内容组件,由于有时候i有的界面的header内容是不一样的,因此要用到兄弟组件的相互通信,这个时候我首先选择了bu ...

  10. Warning: skipping non-radio button in group. 的处理

    1)把你的第一个Radio选中group属性: 2)把你“这个组中”的最后一个Raido控件“后”的一个控件(指得是控件添加先后的顺序,可以用ctrl+d来修改顺序)也选中group属性,如最后一个R ...