Is it possible to print using different colors in ipython's Notebook?

后端 未结 12 1153
孤独总比滥情好
孤独总比滥情好 2020-12-23 09:15

Is it somehow possible to have certain output appear in a different color in the IPython Notebook? For example, something along the lines of:

 print(\"Hello          


        
12条回答
  •  南方客
    南方客 (楼主)
    2020-12-23 09:59

    There is the colored library (pip install colored), which you can use to modify a string to get color codes to modify how it is printed. Example use:

    import colored
    print(colored.bg("white") + colored.fg("red") + "Hello world!")
    

提交回复
热议问题