pythonpython-click

How to set only one word in a specific color using Click.secho


I'm using the click module.

pip install click

This gives me red text

import click
click.secho('Error: This error is ...xx', fg='red')

Now I want that only 'Error:' is shown in red. How can I do this using click.secho?


Solution

  • Use click.echo with click.style

    click.echo(click.style("Error", fg="red") + ": This error is...")