prettytable模块(格式化打印内容)
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模块(格式化打印内容)的更多相关文章
- Python3之PrettyTable模块
一. 简介 Python通过prettytable模块将输出内容如表格方式整齐输出,python本身并不内置,需要独立安装该第三方库. 二. 安装 方式一:pip安装 >>> pip ...
- Python模块——PrettyTable 模块
简介 PrettyTable 是python中的一个第三方库,可用来生成美观的ASCII格式的表格,十分实用. 安装 pip install prettytable 示例 从已有文件创建 CSV fr ...
- python prettytable模块
简介 Python通过PrettyTable模块可以将输出内容如表格方式整齐地输出. 安装 pip install prettytable 1 示例 from prettytable import P ...
- Python之读取用户指令和格式化打印
Python之读取用户指令和格式化打印 一.读取用户指令 当你的程序要接收用户输入的指令时,可以用input函数: name = input("请输入你的名字:") print(& ...
- console 中的格式化打印(占位符),和样式定义
格式化打印 Gecko 9.0 (Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6) 首次发布对string substitutions的支持.你可以在传递给 ...
- C#程序调用CodeSoft预先设计好的标签模块实现打印功能
if (this.tbSetLabel.Text.Trim() == "") { MessageBox.Show("请先 Enter 选择标签模板文件!", & ...
- 3515 如何调试AT指令、查看拨号模块的打印
冯sir给了一个在设备运行的程序serial,运行起来后可以敲指令输入AT指令,具体步骤如下: 1.将serial文件从U盘拷贝到设备里,U盘在设备系统下的目录是/stm/udisk/0/,但是注意设 ...
- Java获取当前时间年月日、时间格式化打印、字符串转日期
package com.sysc.simple; import java.text.ParseException; import java.text.SimpleDateFormat; import ...
- 如何修改int的打印内容——史上最难的JAVA面试题
序 今天看到了一个比较特别的面试题,考察的是如何改变int的System.out.print的结果.题目如下: 下面的一句话"这是初级java实习生面试题"非常挑衅的激起了大家做题 ...
随机推荐
- Codeforces Round #249 (Div. 2)-D
这场的c实在不想做,sad. D: 标记一下每个点8个方向不经过黑点最多能到达多少个黑点. 由题意可知.三角形都是等腰三角形,那么我们就枚举三角形的顶点. 对于每个定点.有8个方向能够放三角形. 然后 ...
- webpack wepack-dev-server 对应版本
webpack wepack-dev-server 对应版本 事情起因是使用 extract-text-webpack-plugin 对 css 和 js 打包进出现 Tapable.plugin i ...
- 在Qt中如何使用QtDesigner创建的UI文件(一) (转)
使用Qt有一些时间了,一直在IDE环境(qtcreator和VS2003+集成器)中使用,自然少了很多麻烦的步骤.但是在享受这种便利的同时,我们也失去了理解更多知识背后的点滴.在IDE中,如果我们要开 ...
- 基于Spring Boot和Spring Cloud实现微服务架构
官网的技术导读真的描述的很详细,虽然对于我们看英文很费劲,但如果英文不是很差,请选择沉下心去读,你一定能收获好多.我的学习是先从Spring boot开始的,然后接触到微服务架构,当然,这一切最大的启 ...
- StreamTool
public class StreamTool { //从流中读取数据 public static byte[] read(InputStream inStream) throws Exception ...
- Hibernate学习6—Hibernate 映射类型
第一节:基本类型映射 com.cy.model.Book.java: package com.cy.model; import java.sql.Blob; import java.util.Date ...
- POJ 2566 Bound Found(尺取法,前缀和)
Bound Found Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 5207 Accepted: 1667 Spe ...
- virtual Box centos7 公司网络环境下不能联网的解决方案
首先感谢@采蘑菇的东峰的博客 的分享 原文:http://blog.sina.com.cn/s/blog_8d92d7580102vhky.html ------------------------- ...
- Ajax显示隐藏
$(function(){ $('#search').click(function(){ if($(".search_div").is(":visible")) ...
- node中express的中间件之cookieParser
cookieParser中间件用于获取web浏览器发送的cookie中的内容.在使用了cookieParser中间件后, 代表客户端请求的htto.IncomingMessage对象就具有了一个coo ...