from rich.text import Text text = Text("Hello, World!") text.stylize("bold underline red on white") print(text)
from rich.text import Text text = Text("Python is my favorite language") text.highlight_regex("python", "bold red") print(text)In this example, we create a Text object with the string "Python is my favorite language" and then highlight the word "Python" using a regular expression with the options bold text and red color. We then print the stylized text to the console. Overall, Python rich.text is a useful package library for making console output more visually appealing and easier to read.