使用python处理表格:python-texttable官方使用说明
2016-01-18 19:47
1121 查看
Example:
from texttable import Texttable, get_color_string, bcolors table = Texttable() table.set_cols_align(["l", "r", "c"]) table.set_cols_valign(["t", "m", "b"]) table.add_rows([ [get_color_string(bcolors.GREEN, "Name Of Person"), "Age", "Nickname"], ["Mr\nXavier\nHuon", 32, "Xav'"], [get_color_string(bcolors.BLUE,"Mr\nBaptiste\nClement"), 1, get_color_string(bcolors.RED,"Baby")] ]) print(table.draw() + "\n") table = Texttable() table.set_deco(Texttable.HEADER) table.set_cols_dtype(['t', # text 'f', # float (decimal) 'e', # float (exponent) 'i', # integer 'a']) # automatic table.set_cols_align(["l", "r", "r", "r", "l"]) table.add_rows([["text", "float", "exp", "int", "auto"], ["abcd", "67", 654, 89, 128.001], ["efghijk", 67.5434, .654, 89.6, 12800000000000000000000.00023], ["lmn", 5e-78, 5e-78, 89.4, .000000000000128], ["opqrstu", .023, 5e+78, 92., 12800000000000000000000]]) print(table.draw())
Result:
相关文章推荐
- python (1)一个简单的爬虫: python 在windows下 创建文件夹并写入文件
- 找出假币
- python学习笔记-Day1
- Python学习之--文件操作
- 在Window平台下安装xgboost的Python版本
- Python求索之路2——深浅拷贝&函数
- python:编写登陆接口(day 1)
- zabbix使用微信报警python脚本
- Python 5.1 使用 __slots__
- Python脚本运行出现语法错误:IndentationError: unindent does not match any outer indentation level
- python 写excal
- python 字符编码
- python(1) - 变量小测试
- Python-strip()方法
- python 对象与变量
- python 数据类型及运算符
- [python] - logging日志模块
- Python 第五章 面向对象高级编程
- 使用python来调试串口
- Python入门1