#!/usr/bin/python

def inred(s):

    return"%s[31;2m%s%s[0m"%(chr(27), s, chr(27))

def ingreen(s):

    return"%s[42;2m%s%s[0m"%(chr(27), s, chr(27))

def inyellow(s):

    return"%s[43;2m%s%s[0m"%(chr(27), s, chr(27))

def inpupure(s):

    return"%s[45;2m%s%s[0m"%(chr(27), s, chr(27))

def inblue(s):

    return"%s[44;2m%s%s[0m"%(chr(27), s, chr(27))

print inred('red')

print ingreen('green')

print inyellow('yellow')

print inpupure('pupure')

print inblue('blue')


上面的部分,可以写成一个函数或者直接import导入使用