[Python] How do I customize text color in IPython?

Discussão em 'Python' iniciado por Stack, Março 8, 2025.

  1. Stack

    Stack Membro Participativo

    I'd like to customize the color of text in IPython, but am not sure how to do it.

    I know that in Python, I can do this by ending sys.ps1 and sys.ps2 with an ANSI color code such as

    sys.ps1=">>> \001\033[0m\033[34m\002"


    But the corresponding approach, using PromptManager.in_template, does not work for IPython. For example

    c = get_config()
    c.PromptManager.in_template = 'In [{count}] : {color.Blue}'


    has no effect on the color of text after the prompt.

    Is there a way to change the color of text in IPython?

    Continue reading...

Compartilhe esta Página