Skip to main content

colorstr

colorstr(obj: Any, color: Union[COLORSTR, int, str] = COLORSTR.BLUE, fmt: Union[FORMATSTR, int, str] = FORMATSTR.BOLD) -> str

  • Description: This function is used to convert Python objects into colored strings.

  • Parameters:

    • obj (Any): Python object to be converted into a colored string.
    • color (Union[COLORSTR, int, str]): Color of the object. Default is COLORSTR.BLUE.
    • fmt (Union[FORMATSTR, int, str]): Format of the object. Default is FORMATSTR.BOLD.
  • Returns:

    • str: Colored string.
  • Example:

    import docsaidkit as D

    # Print blue color string
    blue_str = D.colorstr('This is blue color string.', color='blue')
    print(blue_str)

    # Print red color string with bold format
    red_str = D.colorstr('This is red color string with bold format.', color='red', fmt='bold')
    print(red_str)