Python模块之"prettytable"
Python模块之"prettytable"
摘要: Python通过prettytable模块可以将输出内容如表格方式整齐的输出。(对于用Python操作数据库会经常用到)
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..tar.gz [root@opsedu prettytable-0.7.]# python setup.py build
running build
running build_py
creating build
creating build/lib
copying prettytable.py -> build/lib [root@opsedu prettytable-0.7.]# 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.-py2..egg
creating /usr/lib/python2./site-packages/prettytable-0.7.-py2..egg
Extracting prettytable-0.7.-py2..egg to /usr/lib/python2./site-packages
Adding prettytable 0.7. to easy-install.pth file Installed /usr/lib/python2./site-packages/prettytable-0.7.-py2..egg
Processing dependencies for prettytable==0.7.
Finished processing dependencies for prettytable==0.7.
4、测试pretty模块
>>> import tab
>>> from prettytable import PrettyTable
>>> row = PrettyTable()
>>> row.field_names = ["Name", "Age","Country","City"]
>>> row.add_row(['shaw','','China','Shanghai'])
>>> row.add_row(['charle','','China','Xuzhou'])
>>> row.add_row(['jack','','United States','Washington'])
>>> print row
+--------+-----+---------------+------------+
| Name | Age | Country | City |
+--------+-----+---------------+------------+
| shaw | 23 | China | Shanghai |
| charle | 29 | China | Xuzhou |
| jack | 32 | United States | Washington |
+--------+-----+---------------+------------+
本文转至: https://my.oschina.net/u/2428313/blog/489661
Python模块之"prettytable"的更多相关文章
- python模块——PrettyTable
python模块——PrettyTable 一. 简介 Python通过prettytable模块将输出内容如表格方式整齐输出,可用来生成美观的ASCII格式的表格,十分实用. python本身并不内 ...
- [转]Python 模块收集
Python 模块收集 转自:http://kuanghy.github.io/2017/04/04/python-modules Python | Apr 4, 2017 | python 工具 a ...
- 使用C/C++写Python模块
最近看开源项目时学习了一下用C/C++写python模块,顺便把学习进行一下总结,废话少说直接开始: 环境:windows.python2.78.VS2010或MingW 1 创建VC工程 (1) 打 ...
- Python模块之configpraser
Python模块之configpraser 一. configpraser简介 用于处理特定格式的文件,其本质还是利用open来操作文件. 配置文件的格式: 使用"[]"内包含 ...
- python 学习第五天,python模块
一,Python的模块导入 1,在写python的模块导入之前,先来讲一些Python中的概念性的问题 (1)模块:用来从逻辑上组织Python代码(变量,函数,类,逻辑:实现一个功能),本质是.py ...
- windows下安装python模块
如何在windows下安装python模块 1. 官网下载安装包,比如(pip : https://pypi.python.org/pypi/pip#downloads) pip-9.0.1.tar. ...
- 安装第三方Python模块,增加InfoPi的健壮性
这3个第三方Python模块是可选的,不安装的话InfoPi也可以运行. 但是如果安装了,会增加InfoPi的健壮性. 目录 1.cchardet 自动检测文本编码 2.lxml 用于解析 ...
- Python基础篇【第5篇】: Python模块基础(一)
模块 简介 在计算机程序的开发过程中,随着程序代码越写越多,在一个文件里代码就会越来越长,越来越不容易维护. 为了编写可维护的代码,我们把很多函数分组,分别放到不同的文件里,这样,每个文件包含的代码就 ...
- python 模块加载
python 模块加载 本文主要介绍python模块加载的过程. module的组成 所有的module都是由对象和对象之间的关系组成. type和object python中所有的东西都是对象,分为 ...
随机推荐
- linux下交叉编译go项目
1:下载go源码,以1.7.1版本为例: wget https://storage.googleapis.com/golang/go1.7.1.linux-amd64.tar.gz 2:解压源码 ta ...
- Android开发工具: AS, Gradle, Git等
(一)史上最详细的Android Studio系列教程 你还没有使用Android Studio + Gradle么?那就有点太落伍了,下面自己原创总结了Android Studio的一系列教程,图文 ...
- asp.net mvc 权限过滤和单点登录(禁止重复登录)
1.权限控制使用controller和 action来实现,权限方式有很多种,最近开发项目使用控制控制器方式实现代码如下 /// <summary> /// 用户权限控制 /// < ...
- Centos7 下面安装 MySql 客户端
Workench 是官发发布的Mysql客户端,是Linux下面比较通用的了, 如果使用X界面,可以试着熟悉下. 下载链接: http://cdn.mysql.com//Downloads/MySQL ...
- 他(he)(钟神)
他[问题描述]一张长度为N的纸带,我们可以从左至右编号为0 −N(纸带最左端标号为0) .现在有M次操作,每次将纸带沿着某个位置进行折叠,问所有操作之后纸带的长度是多少.[输入格式]第一行两个数字N, ...
- ThinkPhp 3.2 ajax无刷新分页(未完全改完,临时凑合着用)
临时更改后的page类(很多地方没修改...因为笔者PHP没学好..)如下: <?phpnamespace Fenye\libs; /** file: page.class.php 完美分 ...
- jquery理财贷款计算器
先放效果图,如下: 需要引入jquery ,bootstrap jq代码如下: function pCalculator(amount,term,rating,repayway){ var zhong ...
- web前端基础知识-(六)web框架
一.web框架本质 众所周知,对于所有的Web应用,本质上其实就是一个socket服务端,用户的浏览器其实就是一个socket客户端. #!/usr/bin/env python #coding:ut ...
- 制作宅基腐主页 && 制作个人简历--材料:BootStrap
宅基腐主页 主页分为四大板块:导航栏,轮播图,主页内容,相关信息. 导航栏:<nav>标签,class="navbar",navbar-inverse为反色,navba ...
- android 一些常用开源框架
网络请求compile 'com.squareup.okhttp:okhttp:2.6.0'okhttp依赖compile 'com.squareup.okio:okio:1.6.0'json解析co ...