-
Is there any way to retrieve the raw string of a For example, say I have some padding Is there any supported way to retrieve what would go in the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Probably the easiest way to do this is to capture the output via import io
from rich import console
con = console.Console(file=io.StringIO(), force_terminal=True)
con.print("[bold red]Hello[/] World")
str_output = con.file.getvalue()
print(f" {str_output}") |
Beta Was this translation helpful? Give feedback.
-
See also https://rich.readthedocs.io/en/latest/console.html#capturing-output |
Beta Was this translation helpful? Give feedback.
Probably the easiest way to do this is to capture the output via
io.StringIO
Docs for more info.