python terminal colour printing (termcolor)

/ Published in: Python
Save to your folder(s)

Quick method for creating coloured tty in python terminal using 'termcolor'

$ pip install termcolor;

Copy this code and paste it in your HTML
  1. try:
  2. import termcolor
  3. from termcolor import colored
  4. except: print "No colours :("
  6. def p(*args, **kargs):
  7. color = kargs.get('color', None)
  9. if color and termcolor:
  10. for x in args:
  11. sys.stdout.write(colored(x, color) + '\n')
  12. else:
  13. sys.stdout.write(*args)

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.