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
๐ŸŒ
PyPI
pypi.org โ€บ project โ€บ tabulate
tabulate ยท PyPI
Pretty-print tabular data in Python, a library and a command-line utility.
      ยป pip install tabulate
    
Published ย  Mar 04, 2026
Version ย  0.10.0
๐ŸŒ
DataCamp
datacamp.com โ€บ tutorial โ€บ python-tabulate
Python Tabulate: A Full Guide | DataCamp
September 5, 2024 - The tabulate library provides a command-line utility to help you display tables directly from the command line or terminal. This command-line utility allows you to generate the tables without writing additional Python code.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ introduction-to-python-tabulate-library
Introduction to Python Tabulate Library - GeeksforGeeks
July 23, 2025 - The Python tabulate module is a library and a command-line utility that displays data in a visually appealing format (tabulate format). Whether working with lists, dictionaries, pandas DataFrames, or other forms of structured data, the tabulate ...
๐ŸŒ
Python for Network Engineers
pyneng.readthedocs.io โ€บ en โ€บ latest โ€บ book โ€บ 12_useful_modules โ€บ tabulate.html
tabulate - Python for network engineers
In [27]: print(tabulate(list_of_dict, headers='keys', tablefmt='pipe', stralign='center')) | Interface | IP | Status | Protocol | |:---------------:|:---------:|:--------:|:----------:| | FastEthernet0/0 | 15.0.15.1 | up | up | | FastEthernet0/1 | 10.0.12.1 | up | up | | FastEthernet0/2 | 10.0.13.1 | up | up | | Loopback0 | 10.1.1.1 | up | up | | Loopback100 | 100.0.0.1 | up | up |
Top answer
1 of 16
1042

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.

๐ŸŒ
GitHub
github.com โ€บ astanin โ€บ python-tabulate
GitHub - astanin/python-tabulate: Pretty-print tabular data in Python, a library and a command-line utility. Repository migrated from bitbucket.org/astanin/python-tabulate. ยท GitHub
Pretty-print tabular data in Python, a library and a command-line utility. Repository migrated from bitbucket.org/astanin/python-tabulate. - astanin/python-tabulate
Starred by 2.5K users
Forked by 180 users
Languages ย  Python
Find elsewhere
๐ŸŒ
GitHub
github.com โ€บ thruston โ€บ python-tabulate
GitHub - thruston/python-tabulate: A neat-text-table filter
Many of my Python scripts create tables of data that I need to share in plain text (on Slack for example), and I often found myself loading the output into Vim just so I could tidy it up with tabulate.
Author ย  thruston
๐ŸŒ
Analytics Vidhya
analyticsvidhya.com โ€บ home โ€บ comprehensive guide to pythonโ€™s tabulate library
Comprehensive Guide to Python's Tabulate Library - Analytics Vidhya
May 29, 2025 - Learn everything about python's Tabulate category, how to use, what are the different features, applications, examples and more.
๐ŸŒ
AskPython
askpython.com โ€บ home โ€บ python tabulate module: how to easily create tables in python?
Python tabulate module: How to Easily Create Tables in Python? - AskPython
June 8, 2023 - Python tabulate makes creating and formatting tables easy and efficient. Start by importing the module. You can then create a table by storing your data in a nested list and passing it to the tabulate function. To enhance the look of your table, use the tablefmt attribute and set it to grid for a bordered table, or fancy_grid for a more sophisticated border.
๐ŸŒ
Medium
medium.com โ€บ @jainsnehasj6 โ€บ mastering-tabulate-in-python-create-beautiful-tables-effortlessly-50f70a75862c
Mastering Tabulate in Python: Create Beautiful Tables Effortlessly | by Sneha Jain | Medium
November 4, 2025 - This creates a new folder named venv containing a clean Python environment. ... from tabulate import tabulate data = [ ["Apple", 10], ["Banana", 5], ["Orange", 8], ["Grapes", 12], ["Mango", 7] ] print(tabulate(data))
๐ŸŒ
Readthedocs
pyhdust.readthedocs.io โ€บ tabulate.html
tabulate: auxiliary module to tablature matrix โ€” Python tools for the BeACoN group Stable documentation
>>> tsv = simple_separated_format("\t") ; tabulate([["foo", 1], ["spam", 23]], tablefmt=tsv) == 'foo \t 1' + '\nspam\t23' True
๐ŸŒ
Packetswitch
packetswitch.co.uk โ€บ how-to-create-tables-python-tabulate-module
How to Create Tables with Python Tabulate Module
April 26, 2024 - The headers="keys" argument tells Tabulate to automatically use the keys from our dictionaries ('Name', 'Age', 'City') as headers for the columns. This results in a neatly formatted table where each row corresponds to the information of one person, and columns are clearly labelled for easy reading. Up next, let's see how to make numbers in our tables look neat and tidy. We'll use Python's Tabulate module to line up numbers to the right and show prices with just the right amount of decimal points.
๐ŸŒ
360DigiTMG
360digitmg.com โ€บ blog โ€บ python-tabulate
Python Tabulate: Install Tabulate in Python - 360DigiTMG
August 25, 2024 - In this case study, we'll use Tabulate to analyse and present sales data for a fictional online store. The dataset contains product names, prices, and monthly sales. Code snippet respective to this case study is given below. ... Also, check this Python Institute in Hyderabad to start a career ...
๐ŸŒ
LinkedIn
linkedin.com โ€บ pulse โ€บ effortless-data-tabulation-python-tabulate-library-360-digitmg
Effortless Data Tabulation in Python with Tabulate Library
September 8, 2023 - It's a good practice to work within a virtual environment to avoid conflicts with other Python packages. If you're not using a virtual environment, you can skip this step. Create a virtual environment (replace myenv with your preferred environment name): ... Once you're in your virtual environment (if you're using one), you can install the tabulate library using the following command:
๐ŸŒ
Pickl
pickl.ai โ€บ home โ€บ python programming โ€บ how to tabulate data in python?
How to Tabulate Data in Python?- Pickl.AI
September 6, 2024 - Learn about How to Tabulate Data In Python from this blog. Learn about the process of tabulating data in Python in a structured format.
๐ŸŒ
Medium
medium.com โ€บ @HeCanThink โ€บ tabulate-your-go-to-solution-for-stylish-tables-in-python-35ede5145e28
Tabulate: Your Go-To Solution for Stylish Tables in Python ๐Ÿ‘‰ | by Manoj Das | Medium
August 19, 2023 - Tabulate: Your Go-To Solution for Stylish Tables in Python ๐Ÿ‘‰ What is Tabulate? How to create formatted tabular data in Python. Tabulate in Python is a popular package that allows you to easily โ€ฆ
๐ŸŒ
LearnPython.com
learnpython.com โ€บ blog โ€บ print-table-in-python
How to Pretty-Print Tables in Python | LearnPython.com
For analytics reports or scientific publications, there are various latex formats as well as support for publishing tables in the popular project management software Jira or on GitHub. Hereโ€™s an example showing how you can use one line of Python to prepare tabular data to be published online using the html format:
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 69176549 โ€บ how-to-use-tabulate-module-with-user-input-and-loops-in-python
How to use tabulate module with user input and loops in Python? - Stack Overflow
from array import array as arr import numpy as np from tabulate import * marks = [] stu_mks = input("Enter the marks of the students(entering STOP would end the process): ") marks.append(stu_mks) while stu_mks.lower() != 'stop': stu_mks = input("Enter the marks of the students(entering STOP would end the process): ") marks.append(stu_mks) del marks[-1] array_marks = np.array(marks) float_marks = array_marks.astype(np.float) avg = 0 for i in float_marks: avg += i print("The average marks are", avg / len(float_marks)) marks_list = [] remarks_list = [] for x in float_marks: if x % 1 == 0: marks_l