colorstr
-
Description: This function is used to convert a Python object into a string with color.
-
Parameters
- obj (
Any
): The Python object to be converted into a colored string. - color (
Union[COLORSTR, int, str]
): The color of the object. Default isCOLORSTR.BLUE
. - fmt (
Union[FORMATSTR, int, str]
): The format of the object. Default isFORMATSTR.BOLD
.
- obj (
-
Returns
- str: A string with color.
-
Example
import capybara as cb
# Print blue color string
blue_str = cb.colorstr('This is blue color string.', color='blue')
print(blue_str)
# Print red color string with bold format
red_str = cb.colorstr('This is red color string with bold format.', color='red', fmt='bold')
print(red_str)