Wondering

[Python] ANSI escape code

[Python] ANSI escape code

example:

print ’033[33;46;1m’ + ‘some red text’

033[ = ESC , escape code


ESC [ <param> ; <param> … <command>

ESC [ 0 m # reset all (colors and brightness)
ESC [ 1 m # bright
ESC [ 2 m # dim (looks same as normal brightness)
ESC [ 22 m # normal brightness

# FOREGROUND:
ESC [ 30 m # black
ESC [ 31 m # red
ESC [ 32 m # green
ESC [ 33 m # yellow
ESC [ 34 m # blue
ESC [ 35 m # magenta
ESC [ 36 m # cyan
ESC [ 37 m # white
ESC [ 39 m # reset

# BACKGROUND
ESC [ 40 m # black
ESC [ 41 m # red
ESC [ 42 m # green
ESC [ 43 m # yellow
ESC [ 44 m # blue
ESC [ 45 m # magenta
ESC [ 46 m # cyan
ESC [ 47 m # white
ESC [ 49 m # reset

# cursor positioning
ESC [ x;y H # position cursor at x,y

# clear the screen
ESC [ mode J # clear the screen. Only mode 2 (clear entire screen)
. # is supported. It should be easy to add other modes,
. # let me know if that would be useful.

Ref:

http://en.wikipedia.org/wiki/ANSI_escape_code

http://pypi.python.org/pypi/colorama

發表迴響

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

連結到 %s

Follow

Get every new post delivered to your Inbox.