آموزش پایتون
87 subscribers
282 photos
21 videos
81 files
178 links
ارتباط با ما:
@learnpythonicyBot

لینک گروه چت:
https://t.me/learnpythonicychat

لینک چنل ایتا:
https://eitaa.com/learnpythonicy
Download Telegram
Creating Table Using Python

🦹‍♀️تا حالا با پایتون جدول ساختی؟



# pip install rich
from rich.console import Console
from rich.table import Table

# https://t.me/learnpythonicy

# Initialize the console
console = Console()
# Create a table
table = Table(title="Sample Data Table")

# Add columns
table.add_column("State", justify="left", style="cyan", no_wrap=True)
table.add_column("Murder Rate", justify="right", style="magenta")
table.add_column("Population", justify="right", style="green")
table.add_column("Illiteracy Rate", justify="right", style="blue")
table.add_column("Income", justify="right", style="yellow")

# Add rows
data = [
['Alabama', '13.2', '236', '58', '21.2'],
['Alaska', '10.0', '263', '48', '44.5'],
['Arizona', '8.1', '294', '80', '31.0'],
]

for row in data:
table.add_row(*row)

# Print the table
console.print(table)


#rich | #table | LearningPython