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

2、下载prettytable模块

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

3、安装PrettyTable模块

[root@opsedu ~]# wget https://pypi.python.org/packages/source/P/PrettyTable/prettytable-0.7.2.tar.gz
[root@opsedu ~]# tar -zxvf prettytable-0.7.2.tar.gz [root@opsedu prettytable-0.7.2]# python setup.py build
running build
running build_py
creating build
creating build/lib
copying prettytable.py -> build/lib [root@opsedu prettytable-0.7.2]# python setup.py install   # 安装prettytable
running install
running bdist_egg
running egg_info
writing prettytable.egg-info/PKG-INFO
writing top-level names to prettytable.egg-info/top_level.txt
writing dependency_links to prettytable.egg-info/dependency_links.txt
reading manifest file 'prettytable.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'prettytable.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
copying build/lib/prettytable.py -> build/bdist.linux-x86_64/egg
byte-compiling build/bdist.linux-x86_64/egg/prettytable.py to prettytable.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying prettytable.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying prettytable.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying prettytable.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying prettytable.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/prettytable-0.7.2-py2.6.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing prettytable-0.7.2-py2.6.egg
creating /usr/lib/python2.6/site-packages/prettytable-0.7.2-py2.6.egg
Extracting prettytable-0.7.2-py2.6.egg to /usr/lib/python2.6/site-packages
Adding prettytable 0.7.2 to easy-install.pth file Installed /usr/lib/python2.6/site-packages/prettytable-0.7.2-py2.6.egg
Processing dependencies for prettytable==0.7.2
Finished processing dependencies for prettytable==0.7.2

4、测试pretty模块

>>> import tab
>>> from prettytable import PrettyTable>>> row = PrettyTable()
>>> row.field_names = ["Name", "Age","Country","City"]
>>> row.add_row(['shaw','23','China','Shanghai'])
>>> row.add_row(['charle','29','China','Xuzhou'])
>>> row.add_row(['jack','32','United States','Washington'])
>>> print row
+--------+-----+---------------+------------+
|  Name  | Age |    Country    |    City    |
+--------+-----+---------------+------------+
|  shaw  |  23 |     China     |  Shanghai  |
| charle |  29 |     China     |   Xuzhou   |
|  jack  |  32 | United States | Washington |
+--------+-----+---------------+------------+

附件列表

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. Delphi格式化函数Format、FormatDateTime和FormatFloat详解

    转自:http://outofmemory.cn/code-snippet/7631/Delphi-format-hua-function-Format-FormatDateTime-FormatFl ...

  2. THREE.OrbitControls参数控制

    // Set to false to disable this control//鼠标控制是否可用 this.enabled = true; // "target" sets th ...

  3. tomcat错误:The page you tried to access (/manager/login.do) does not exist

    今天在idea上跑一个项目,所有配置都正常,其他接口测试也正常.唯独“/manage/user”接口在测试的时候后台没反应,也就是程序根本没往下走,postman测试显示如下: 浏览器范围url连接显 ...

  4. POJ1741 Tree + BZOJ1468 Tree 【点分治】

    POJ1741 Tree + BZOJ1468 Tree Description Give a tree with n vertices,each edge has a length(positive ...

  5. Automating CSS Regression Testing

    The following is a guest post by Garris Shipon . We've touched on the four types of CSS testing here ...

  6. git 获取远程分支

    另一哥们将分支push到库中,我怎么获取到他的分支信息呢? 如果安装了git客户端,直接选择fetch一下,就可以获取到了. 如果用命令行,运行 git fetch,可以将远程分支信息获取到本地,再运 ...

  7. wordpress插件汉化包,和使用教程

    点击下载汉化包 解压后上传到该插件的 languages 目录即可

  8. python一些内建函数(map,zip,filter,reduce,yield等)

    python一些内建函数(map,zip,filter,reduce,yield等) map函数 Python实际上提供了一个内置的工具,map函数.这个函数的主要功能是对一个序列对象中的每一个元素应 ...

  9. 2019Falg

    2019的Flag 2018 2018年对我来说是很重要的一年. 毕业--拿到硕士学位. 工作---成功转行进入互联网行业. 有了她. 上半年忙碌于毕业的各种事情,被毕业论文折磨的要疯,顺利走完所有流 ...

  10. 互联网的keyvalue处理

    今天在和许伟讨论系统配置页面得时候,许伟提到了“打通页面”的概念,当时我没太明白,后来才知道是指类似于cloudera里面的配置页面那种,不是列表页,而是展示+编辑在一个页面.刚才想了一下,其实对于这 ...