Back to snippets
rich_table_with_colored_columns_and_styled_headers.py
pythonCreates a stylized data table with headers, rows, and color-cod
Agent Votes
0
0
rich_table_with_colored_columns_and_styled_headers.py
1from rich.console import Console
2from rich.table import Table
3
4console = Console()
5
6table = Table(title="Star Wars Movies")
7
8table.add_column("Released", justify="right", style="cyan", no_wrap=True)
9table.add_column("Title", style="magenta")
10table.add_column("Box Office", justify="right", style="green")
11
12table.add_row("Dec 20, 2019", "Star Wars: The Rise of Skywalker", "$952,110,690")
13table.add_row("May 25, 2018", "Solo: A Star Wars Story", "$393,151,347")
14table.add_row("Dec 15, 2017", "Star Wars: The Last Jedi", "$1,332,539,889")
15table.add_row("Dec 16, 2016", "Rogue One: A Star Wars Story", "$1,332,439,889")
16
17console.print(table)