@@ -5,36 +5,45 @@ For easy printing of ascii tables within python
55
66# Installation:
77
8- pip install -U git+http://github.com/bufordtaylor/python-texttable
8+ ``` bash
9+ pip install -U git+http://github.com/bufordtaylor/python-texttable
10+ ```
11+
912On debian sid
1013
11- apt-get install python-texttable
14+ ``` bash
15+ apt-get install python-texttable
16+ ```
1217
1318
1419# Example:
1520
16- table = Texttable()
17- table.set_cols_align(["l", "r", "c"])
18- table.set_cols_valign(["t", "m", "b"])
19- table.add_rows([ [get_color_string(bcolors.GREEN, "Name Of Person"), "Age", "Nickname"],
20- ["Mr\nXavier\nHuon", 32, "Xav'"],
21- [get_color_string(bcolors.BLUE,"Mr\nBaptiste\nClement"), 1, get_color_string(bcolors.RED,"Baby")] ])
22- print table.draw() + "\\n"
23-
24- table = Texttable()
25- table.set_deco(Texttable.HEADER)
26- table.set_cols_dtype(['t', # text
27- 'f', # float (decimal)
28- 'e', # float (exponent)
29- 'i', # integer
30- 'a']) # automatic
31- table.set_cols_align(["l", "r", "r", "r", "l"])
32- table.add_rows([["text", "float", "exp", "int", "auto"],
33- ["abcd", "67", 654, 89, 128.001],
34- ["efghijk", 67.5434, .654, 89.6, 12800000000000000000000.00023],
35- ["lmn", 5e-78, 5e-78, 89.4, .000000000000128],
36- ["opqrstu", .023, 5e+78, 92., 12800000000000000000000]])
37- print table.draw()
21+ ``` python
22+ from texttable import Texttable, get_color_string, bcolors
23+
24+ table = Texttable()
25+ table.set_cols_align([" l" , " r" , " c" ])
26+ table.set_cols_valign([" t" , " m" , " b" ])
27+ table.add_rows([ [get_color_string(bcolors.GREEN , " Name Of Person" ), " Age" , " Nickname" ],
28+ [" Mr\n Xavier\n Huon" , 32 , " Xav'" ],
29+ [get_color_string(bcolors.BLUE ," Mr\n Baptiste\n Clement" ), 1 , get_color_string(bcolors.RED ," Baby" )] ])
30+ print (table.draw() + " \n " )
31+
32+ table = Texttable()
33+ table.set_deco(Texttable.HEADER )
34+ table.set_cols_dtype([' t' , # text
35+ ' f' , # float (decimal)
36+ ' e' , # float (exponent)
37+ ' i' , # integer
38+ ' a' ]) # automatic
39+ table.set_cols_align([" l" , " r" , " r" , " r" , " l" ])
40+ table.add_rows([[" text" , " float" , " exp" , " int" , " auto" ],
41+ [" abcd" , " 67" , 654 , 89 , 128.001 ],
42+ [" efghijk" , 67.5434 , .654 , 89.6 , 12800000000000000000000.00023 ],
43+ [" lmn" , 5e-78 , 5e-78 , 89.4 , .000000000000128 ],
44+ [" opqrstu" , .023 , 5e+78 , 92 ., 12800000000000000000000 ]])
45+ print (table.draw())
46+ ```
3847
3948# Result:
4049
0 commit comments