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中所有的东西都是对象,分为 ...
随机推荐
- Appium环境搭建+cordova
1.安装JDK 配置JAVA_HOME(变量值为jdk的安装目录)以及Path path值如下: 验证是否生效 2.安装node.js 选择适合自己的版本官网直接下载https://nodejs.or ...
- BZOJ1192 [HNOI2006]鬼谷子的钱袋
本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump/ ...
- 动手实践记录(利用django创建一个博客系统)
1.添加一个分类的标签,和主表的关系是 外键 class Category(models.Model): """ 分类 """ name = ...
- python应用案例
安装库 : PIL(Image.ImageDraw.ImageFont.zlib).jpeg 常见问题 (1) Could not find a version that satisfies the ...
- java 枚举的简单应用。
枚举,就是保存着原始的<key,value> 在代码中会经常用到.为了不坑自己,记录一下笔记 package com.fortunedr.common.constant; public e ...
- rmarkdown教程
https://github.com/yihui/r-ninja/blob/master/11-auto-report.md http://rpubs.com/about/getting-starte ...
- thinkphp3.2.3中U()方法和redirect()方法区别
今天博主看3.1的教程,学着3.2,就遇到了这个坑,怎么就是不跳转呢,很纳闷!! 在thinkphp3.1 中 U()方法是可以执行跳转的(看视频教程里面是可以的,博主没有测试过). 但是在think ...
- vector it->和*it
//每次写代码总是被迭代器的iter->和*iter弄晕,主要是被protobuf弄晕了 #include <vector> struct test{ test(){ memset( ...
- jq使用技巧
1. 如何创建嵌套的过滤器 //允许你减少集合中的匹配元素的过滤器, //只剩下那些与给定的选择器匹配的部分.在这种情况下, //查询删除了任何没(:not)有(:has) //包含class为 ...
- js访问php,返回数组时的注意事项
用ajax访问php脚本返回值是数组的时候,php端需要使用json_encode()函数进行转码成json字符串,js端需要用JSON.parse()来吧json字符串转换成数组或对象. 直接返回会 ...