rich
Utilities終端樣式
概述 rich
Rich 是一個用於將富文本寫入終端機的 Python 函式庫。它支援 Markdown 渲染、語法突出顯示、表格、進度條、漂亮列印的回溯以及各種其他格式選項 - 所有這些都具有簡單、富有表現力的 API。
在PyRun的終端機中,Rich 的樣式以格式化輸出的形式出現,使其成為建立精美的 CLI 輸出的出色工具。無論您是要建立資料報告腳本還是只是想要更好的列印報表,Rich 都可以透過 micropip 開箱即用,無需安裝。
程式碼和執行輸出
使用豐富的庫設計面板和表格。
Rich Terminal Tables在編輯器中執行
from rich.console import Console
from rich.table import Table
from rich.panel import Panel
console = Console()
console.print(Panel.fit("[bold green]Welcome to PyRun[/bold green]", border_style="green"))
table = Table(title="Top Programming Languages")
table.add_column("Rank", justify="center", style="cyan", no_wrap=True)
table.add_column("Language", style="magenta")
table.add_column("Type", style="green")
table.add_column("Popular For", style="yellow")
table.add_row("1", "Python", "Dynamic", "Data Science, AI")
table.add_row("2", "JavaScript", "Dynamic", "Web, Node")
table.add_row("3", "TypeScript", "Static", "Large-scale Web")
table.add_row("4", "Rust", "Static", "Systems, WASM")
console.print(table)相關套餐
推薦的 Python 資源
透過相關的互動式教學、備忘單和程式碼比較來擴展您的知識。
Python教學
Python 迴圈:For 與 While 迴圈解釋
了解如何使用 Python 循環來迭代資料。透過互動式範例掌握 for 迴圈、while 迴圈、break、continue 和迴圈最佳實務。
查看資源
操作指南
如何在 Python 中對列表進行排序(升序和降序)
了解如何在 Python 中使用 sort() 方法和sorted() 函數對清單進行排序。發現自訂鍵排序和逆序範例。
查看資源
備忘錄
Python 字串方法備忘單
Python 字串操作的完整參考指南。掌握格式化、搜尋、拆分、取代和檢查字串屬性。
查看資源
語言比較
Python 與 JavaScript:哪種程式語言最好?
Python 和 JavaScript 的全面比較。探索語法差異、效能、用例(後端與前端)和編碼範例。
查看資源