1、查看系统是否已经安装prettytable模块
2、下载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 buildrunning buildrunning build_pycreating buildcreating build/libcopying prettytable.py -> build/lib[root@opsedu prettytable-0.7.2]# python setup.py install # 安装prettytablerunning installrunning bdist_eggrunning egg_infowriting prettytable.egg-info/PKG-INFOwriting top-level names to prettytable.egg-info/top_level.txtwriting dependency_links to prettytable.egg-info/dependency_links.txtreading 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/eggrunning install_librunning build_pycreating build/bdist.linux-x86_64creating build/bdist.linux-x86_64/eggcopying build/lib/prettytable.py -> build/bdist.linux-x86_64/eggbyte-compiling build/bdist.linux-x86_64/egg/prettytable.py to prettytable.pyccreating build/bdist.linux-x86_64/egg/EGG-INFOcopying prettytable.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFOcopying prettytable.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFOcopying prettytable.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFOcopying prettytable.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFOzip_safe flag not set; analyzing archive contents...creating distcreating 'dist/prettytable-0.7.2-py2.6.egg' and adding 'build/bdist.linux-x86_64/egg' to itremoving 'build/bdist.linux-x86_64/egg' (and everything under it)Processing prettytable-0.7.2-py2.6.eggcreating /usr/lib/python2.6/site-packages/prettytable-0.7.2-py2.6.eggExtracting prettytable-0.7.2-py2.6.egg to /usr/lib/python2.6/site-packagesAdding prettytable 0.7.2 to easy-install.pth fileInstalled /usr/lib/python2.6/site-packages/prettytable-0.7.2-py2.6.eggProcessing dependencies for prettytable==0.7.2Finished 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 |+--------+-----+---------------+------------+
来源:
附件列表