Custom Styling of Text with ANSI Escape Codes#
style_text(text, *styles) #
Style text with various options for text and background colors, styling and effects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text | str | The text to be styled. | required |
*styles | Color | BrightColor | ColorVGA | ColorRGB | ColorHSL | ColorHex | BgColor | BgBrightColor | BgColorVGA | BgColorRGB | BgColorHSL | BgColorHex | Effect | str | None | The text and/or background colors, styling and/or effects to be applied to the text. | () |
Returns:
| Type | Description |
|---|---|
str | A new string with the text wrapped in the relevant ANSI escape codes, e.g. |
Example
| Python | |
|---|---|
1 2 3 4 | |
How it appears in the terminal:
% WARNING