How to print colour/color in python?

前端 未结 8 1142
有刺的猬
有刺的猬 2020-12-01 18:38

New to both Python and StackOverflow, I\'d like a little help. I\'d like to print color in Python and have Googled but with little luck :( I\'ve been confused each time and

8条回答
  •  遥遥无期
    2020-12-01 18:57

    Clint (Command Line INterface Tools) is a good library that I've used. It's a multipurpose library for anything to do with the terminal. There are functions in there for colors, yes/no prompts, progress bars, etc.

    Using Clint for colored output looks like this:

    >>> from clint.textui import colored, puts
    >>> puts(colored.red('red text'))
    red text
    

提交回复
热议问题