There are some light and useful python packages for this purpose:

1. tabulate

https://pypi.python.org/pypi/tabulate

from tabulate import tabulate
print(tabulate([['Alice', 24], ['Bob', 19]], headers=['Name', 'Age']))
Name      Age
------  -----
Alice      24
Bob        19

tabulate has many options to specify headers and table format.

print(tabulate(
    [['Alice', 24], ['Bob', 19]],
    headers=['Name', 'Age'],
    tablefmt='orgtbl'))
| Name   |   Age |
|--------+-------|
| Alice  |    24 |
| Bob    |    19 |

2. PrettyTable

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

from prettytable import PrettyTable
t = PrettyTable(['Name', 'Age'])
t.add_row(['Alice', 24])
t.add_row(['Bob', 19])
print(t)
+-------+-----+
|  Name | Age |
+-------+-----+
| Alice |  24 |
|  Bob  |  19 |
+-------+-----+

PrettyTable has options to read data from csv, html, sql database. Also you are able to select subset of data, sort table and change table styles.

3. texttable

https://pypi.python.org/pypi/texttable

from texttable import Texttable
t = Texttable()
t.add_rows([['Name', 'Age'], ['Alice', 24], ['Bob', 19]])
print(t.draw())
+-------+-----+
| Name  | Age |
+=======+=====+
| Alice | 24  |
+-------+-----+
| Bob   | 19  |
+-------+-----+

with texttable you can control horizontal/vertical align, border style and data types.

4. termtables

https://github.com/nschloe/termtables

import termtables as tt

string = tt.to_string(
    [["Alice", 24], ["Bob", 19]],
    header=["Name", "Age"],
    style=tt.styles.ascii_thin_double,
    # alignment="ll",
    # padding=(0, 1),
)
print(string)
+-------+-----+
| Name  | Age |
+=======+=====+
| Alice | 24  |
+-------+-----+
| Bob   | 19  |
+-------+-----+

with texttable you can control horizontal/vertical align, border style and data types.

Other options

  • terminaltables - Easily draw tables in terminal/console applications from a list of lists of strings. Supports multi-line rows.
  • asciitable can read and write a wide range of ASCII table formats via built-in Extension Reader Classes.
Answer from iman on Stack Overflow
🌐
Medium
amrinarosyd.medium.com › prettytable-vs-tabulate-which-should-you-use-e9054755f170
PrettyTable vs. Tabulate: which should you use? | by Amrina Rosyada | Medium
May 8, 2023 - If extensive customization and easy column sorting are crucial for you, PrettyTable is the better choice. On the other hand, if simplicity, performance, and a variety of built-in table formats are more important, Tabulate is the way to go.
🌐
Medium
medium.com › top-python-libraries › which-python-library-creates-the-most-stunning-tables-tabulate-vs-prettytable-7efea0101a70
Which Python Library Creates the Most Stunning Tables: Tabulate vs PrettyTable? | by Ajay Parmar | Top Python Libraries | Medium
April 26, 2025 - While both libraries might have drawn inspiration from each other in certain aspects, Tabulate is more streamlined and suited for quicker, simpler coding, while PrettyTable is perfect for projects that require more flexibility and customization.
Discussions

Which is the most recommended Pretty-print tables module in python? - Software Recommendations Stack Exchange
I have looked at various python modules like tabulate, texttable, terminaltables, prettytable and asciitable. It seemed that tabulate is the most commonly used module but the problem with tabulate ... More on softwarerecs.stackexchange.com
🌐 softwarerecs.stackexchange.com
September 5, 2017
python - Printing Lists as Tabular Data - Stack Overflow
I am quite new to Python and I am now struggling with formatting my data nicely for printed output. I have one list that is used for two headings, and a matrix that should be the contents of the ta... More on stackoverflow.com
🌐 stackoverflow.com
Python format tabular output - Stack Overflow
>>> from tabulate import tabulate ... print(tabulate(table)) ----- ------ ------------- Sun 696000 1.9891e+09 Earth 6371 5973.6 Moon 1737 73.5 Mars 3390 641.85 ----- ------ ------------- ... Yeah, I used this one, and very simple to have a table like structure in just few lines of code! 2016-08-03T07:00:07.6Z+00:00 ... There is a nice module for this in pypi, PrettyTable... More on stackoverflow.com
🌐 stackoverflow.com
PrettyTable Python table structure - Stack Overflow
I wanted to construct a table in the Below format using python. Edit : Sorry for not writing the question properly I have used PrettyTable t = PrettyTable() t.field_names =["TestCase Name",& More on stackoverflow.com
🌐 stackoverflow.com
🌐
Stack Exchange
softwarerecs.stackexchange.com › questions › 45570 › which-is-the-most-recommended-pretty-print-tables-module-in-python
Which is the most recommended Pretty-print tables module in python? - Software Recommendations Stack Exchange
September 5, 2017 - I have looked at various python modules like tabulate, texttable, terminaltables, prettytable and asciitable. It seemed that tabulate is the most commonly used module but the problem with tabulate ...
Top answer
1 of 16
1041

There are some light and useful python packages for this purpose:

1. tabulate

https://pypi.python.org/pypi/tabulate

from tabulate import tabulate
print(tabulate([['Alice', 24], ['Bob', 19]], headers=['Name', 'Age']))
Name      Age
------  -----
Alice      24
Bob        19

tabulate has many options to specify headers and table format.

print(tabulate(
    [['Alice', 24], ['Bob', 19]],
    headers=['Name', 'Age'],
    tablefmt='orgtbl'))
| Name   |   Age |
|--------+-------|
| Alice  |    24 |
| Bob    |    19 |

2. PrettyTable

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

from prettytable import PrettyTable
t = PrettyTable(['Name', 'Age'])
t.add_row(['Alice', 24])
t.add_row(['Bob', 19])
print(t)
+-------+-----+
|  Name | Age |
+-------+-----+
| Alice |  24 |
|  Bob  |  19 |
+-------+-----+

PrettyTable has options to read data from csv, html, sql database. Also you are able to select subset of data, sort table and change table styles.

3. texttable

https://pypi.python.org/pypi/texttable

from texttable import Texttable
t = Texttable()
t.add_rows([['Name', 'Age'], ['Alice', 24], ['Bob', 19]])
print(t.draw())
+-------+-----+
| Name  | Age |
+=======+=====+
| Alice | 24  |
+-------+-----+
| Bob   | 19  |
+-------+-----+

with texttable you can control horizontal/vertical align, border style and data types.

4. termtables

https://github.com/nschloe/termtables

import termtables as tt

string = tt.to_string(
    [["Alice", 24], ["Bob", 19]],
    header=["Name", "Age"],
    style=tt.styles.ascii_thin_double,
    # alignment="ll",
    # padding=(0, 1),
)
print(string)
+-------+-----+
| Name  | Age |
+=======+=====+
| Alice | 24  |
+-------+-----+
| Bob   | 19  |
+-------+-----+

with texttable you can control horizontal/vertical align, border style and data types.

Other options

  • terminaltables - Easily draw tables in terminal/console applications from a list of lists of strings. Supports multi-line rows.
  • asciitable can read and write a wide range of ASCII table formats via built-in Extension Reader Classes.
2 of 16
323

Some ad-hoc code:

row_format ="{:>15}" * (len(teams_list) + 1)
print(row_format.format("", *teams_list))
for team, row in zip(teams_list, data):
    print(row_format.format(team, *row))

This relies on str.format() and the Format Specification Mini-Language.

🌐
Python Central
pythoncentral.io › python-tabulate-creating-beautiful-tables-from-your-data
Python Tabulate: Creating Beautiful Tables from Your Data | Python Central
April 1, 2025 - prettytable: Similar functionality with more styling options · texttable: Focuses on ASCII art tables · pandas.DataFrame.to_string(): Built-in functionality if already using pandas · rich: Advanced console formatting including tables with ...
Find elsewhere
🌐
Abilian
lab.abilian.com › Tech › Python › Useful Libraries › (Pretty) tables in Python
(Pretty) tables in Python - Abilian Innovation Lab
tabulate: tabulate is a library for formatting and printing tables in Python. It can create tables from a variety of data sources, including lists, tuples, and dictionaries. PrettyTable: a simple library to create ASCII tables in Python.
🌐
PyPI
pypi.org › project › tabulate
tabulate · PyPI
At the same time, tabulate is comparable to other table pretty-printers. Given a 10x10 table (a list of lists) of mixed text and numeric data, tabulate appears to be faster than PrettyTable and texttable. The following mini-benchmark was run in Python 3.13.7 on Windows 11 (x64):
      » pip install tabulate
    
Published   Mar 04, 2026
Version   0.10.0
🌐
Arboreus
txt.arboreus.com › 2013 › 03 › 13 › pretty-print-tables-in-python.html
Pretty printing tables in Python
March 13, 2013 - Now tabulate formats data on a per-column basis; per-cell and per-row are also reasonable auto-formatting strategies. Deal with empty cells or occasional textual data in an otherwise numeric column (this may be useful to print tournament cross-tables, for example). ... PrettyTable requires to setup of a pretty-printer in object-oriented style.
🌐
LearnPython.com
learnpython.com › blog › print-table-in-python
How to Pretty-Print Tables in Python | LearnPython.com
Like the tabulate library, the prettytable library also comes with pre-defined formats to help publish tables in different ways. You can publish in a Microsoft-Word-friendly style, for example, and there are formats for JSON and HTML with customization options.
🌐
YouTube
youtube.com › watch
Python(Creating A Table Using The PrettyTable Library/Module) - YouTube
In this table, I have demonstrated how to create a table using the PrettyTable Library. Also watch my other videos on using the Tabulate and Pandas/Dataframe...
Published   March 26, 2023
🌐
Stack Overflow
stackoverflow.com › questions › 71332565 › prettytable-python-table-structure
PrettyTable Python table structure - Stack Overflow
If you want to display the table in the terminal/console. See https://pypi.org/project/tabulate/ or https://pypi.org/project/prettytable/
🌐
Towards Data Science
towardsdatascience.com › home › latest › 3 simple ways to quick generate text-based tables in python
3 Simple Ways to Quick Generate Text-based Tables in Python | Towards Data Science
January 20, 2025 - Tabulate is another library I’d like to recommend. Basically, it is pretty similar to PrettyTable, but I think it is more flexible in customizing the grid compared to PrettyTable.
🌐
PyPI
pypi.org › project › prettytable
prettytable · PyPI
pip install prettytable Copy PIP instructions · Latest version · Released: Nov 14, 2025 · A simple Python library for easily displaying tabular data in a visually appealing ASCII table format · These details have been verified by PyPI · Changelog · Homepage ·
      » pip install prettytable
    
Published   Nov 14, 2025
Version   3.17.0
🌐
Blogger
lino76.blogspot.com › 2016 › 01 › creating-texttables-and-prettytables.html
General: Creating TextTables and PrettyTables using Python
January 21, 2016 - 1. tabulate: https://pypi.python.org/pypi/tabulate · >>> from tabulate import tabulate >>> print tabulate([['Alice', 24], ['Bob', 19]], headers=['Name', 'Age']) Name Age ------ ----- Alice 24 Bob 19 · tabulate has many options to specify headers and table format. >>> print tabulate([['Alice', 24], ['Bob', 19]], headers=['Name', 'Age'], tablefmt='orgtbl') | Name | Age | |--------+-------| | Alice | 24 | | Bob | 19 | 2. PrettyTable: https://pypi.python.org/pypi/PrettyTable
🌐
Medium
medium.com › @qemhal.h › different-ways-to-display-a-table-in-python-d867aefb624a
Different Ways to Display a Table in Python | by Qemhal Haritskhayru | Medium
April 26, 2024 - Just like tabulate, prettytable will automatically create and format your data into a tabular form. While prettytable is less popular than tabulate. It’s actually offer more customization and easier to use.