Adding colors in python interpreter prompt, does not wrap properly

后端 未结 2 861
渐次进展
渐次进展 2021-02-14 11:40

I would like to have a more colorful Python prompt in the terminal, just for readability. I currently have:

sys.ps1 = \'\\033[96m>>> \\033[0m\'
sys.ps2         


        
相关标签:
2条回答
  • 2021-02-14 12:36

    Try the following:

    sys.ps1 = '\001\033[96m\002>>> \001\033[0m\002'
    sys.ps2 = '\001\033[96m\002... \001\033[0m\002'
    

    This answer to a similar question explains why the \001 and \002 are necessary.

    0 讨论(0)
  • 2021-02-14 12:42

    Is there some reason to not use IPython? IPython does provide color prompts, etc. out of the box...

    0 讨论(0)
提交回复
热议问题