How to get styled string? #1458
Answered
by
yashrathi-git
yashrathi-git
asked this question in
Q&A
-
Hello, Ex: >> styled_str = "[red on yellow]test[/]"
>> convert_to_str(styled_str)
'\x1b[31m\x1b[43mtest\x1b[0m' Thank you |
Beta Was this translation helpful? Give feedback.
Answered by
yashrathi-git
Sep 1, 2021
Replies: 1 comment
-
I found a way def convert_to_str(e):
with console.capture() as capture:
console.print(str(e), highlight=False)
str_out = capture.get()
return str_out |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
yashrathi-git
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found a way