V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
Kai
V2EX  ›  Python

termcolor

  •  
  •   Kai · 2015-02-13 23:30:23 +08:00 · 2231 次点击
    这是一个创建于 3368 天前的主题,其中的信息可能已经有所发展或是发生改变。
    from termcolor import colored
    
    print colored('Hello', 'blue') + ", " + colored('V2EX', 'cyan', attrs=['bold'])
    

    https://pypi.python.org/pypi/termcolor

    4 条回复    2015-02-24 20:39:10 +08:00
    caizixian
        1
    caizixian  
       2015-02-14 09:24:33 +08:00
    还在想着怎么解决呢,就看到这个库了。
    多谢分享
    AnyOfYou
        2
    AnyOfYou  
       2015-02-15 16:49:53 +08:00   ❤️ 1
    刚好了解一点这个。如果想了解更多,或者需要定制更多的颜色,可以看看这里 http://en.wikipedia.org/wiki/ANSI_escape_code#Codes
    实际上使用30–37,40–47可以指定8种颜色,也可以用38;5;(0..255)来指定更多的颜色。
    jamiesun
        3
    jamiesun  
       2015-02-24 20:38:37 +08:00
    我这几天也折腾呢,自己用原始方法搞了一个,但是windows下不行
    https://gist.github.com/f057e65c482889d08331.git
    jamiesun
        4
    jamiesun  
       2015-02-24 20:39:10 +08:00
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   761 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 21:00 · PVG 05:00 · LAX 14:00 · JFK 17:00
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.