Adding colors in python interpreter prompt, does not wrap properly

后端 未结 2 855
渐次进展
渐次进展 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.

提交回复
热议问题