prettytable模块(格式化打印内容)

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

        996586-20170616165348900-1068232334.png

2、下载prettytable模块

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

        996586-20170616165353665-1087290520.png

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 |
+--------+-----+---------------+------------+




附件列表

 

转载于:https://www.cnblogs.com/wumingxiaoyao/p/7028301.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值