How to print colored text in Python?

前端 未结 30 2921
谎友^
谎友^ 2020-11-21 04:41

How can I output colored text to the terminal in Python?

30条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-21 05:11

    You could use CLINT:

    from clint.textui import colored
    print colored.red('some warning message')
    print colored.green('nicely done!')
    

    Get it from GitHub.

提交回复
热议问题