Python设置文本文字颜色

#!/usr/bin/env python
# -*- coding:utf-8 -*-

# Python设置文本文字颜色
class bcolors:
    HEADER = '\033[95m'       # pink
    OKBLUE = '\033[94m'       # blue
    OKGREEN = '\033[92m'      # green
    WARNING = '\033[93m'      # yellow
    FAIL = '\033[91m'         # red
    ENDC = '\033[0m'          # black
    BOLD = '\033[1m'          # black+bold
    UNDERLINE = '\033[4m'     # black+underline


print(bcolors.HEADER + "提示:此时文字颜色为pink")
print(bcolors.OKBLUE + "提示:此时文字颜色为blue")
print(bcolors.OKGREEN + "提示:此时文字颜色为green")
print(bcolors.WARNING + "提示:此时文字颜色为yellow")
print(bcolors.FAIL + "提示:此时文字颜色为red")
print(bcolors.ENDC + "提示:此时文字颜色为black")
print(bcolors.UNDERLINE + "提示:此时文字颜色为black+underline")
print(bcolors.BOLD + "提示:此时文字颜色为black+bold")

 

提示:此时文字颜色为pink
提示:此时文字颜色为blue
提示:此时文字颜色为green
提示:此时文字颜色为yellow
提示:此时文字颜色为red
提示:此时文字颜色为black
提示:此时文字颜色为black+underline
提示:此时文字颜色为black+bold

转载于:https://www.cnblogs.com/apollo1616/articles/10199070.html

你可能感兴趣的:(python)