1 python的颜色打印
颜色打印,无论对于python、java还是shell,本身是没有什么区别的,关键是用户可以熟记一些常用的颜色码、加粗、加背景等不同参数,下面给出python工具库的一个简单说明。
class PrintUtils:
checklogger = LoggerUtils.createLogger(__name__, "log/checklogger.log")
redPrint="\033[31m"
greenPrint = "\033[32m"
yellowPrint = "\033[33m"
bluePrint = "\033[34m"
yellowLinePrint = "\033[1;4;33m"
geenLinePrint = "\033[1;4;32m"
geenBackPrint = "\033[1;4;42m"
endPrint="\033[0m"
#red--echo -e "\033[31m${*}\033[0m"
#green -e "\033[32m${*}\033[0m"
##红色打印
def printRed(str):
print(CheckAndTips.redPrint, str, CheckAndTips.endPrint)
def printGreenBash(str):
print(CheckAndTips.greenPrint, str, CheckAndTips.endPrint, end=' ')
def printGreen(str):
print(CheckAndTips.greenPrint, str, CheckAndTips.endPrint)
def printYellow(str):
print(CheckAndTips.yellowPrint, str, CheckAndTips.endPrint)
def printYellowBash(str):
print(CheckAndTips.yellowPrint, str, CheckAndTips.endPrint, end=' ')
def printBlue(str):
print(CheckAndTips.bluePrint, str, CheckAndTips.endPrint)
def printYellowLine(str):
print(CheckAndTips.yellowLinePrint, str, CheckAndTips.endPrint)
def printLine(str):
print(CheckAndTips.geenLinePrint, str, CheckAndTips.endPrint)
这是之前总结的颜色编码的一个shell备忘:
#!/usr/bin/env bash
echo -e "\e[1;31m 字体颜色设置: 重置=0,黑色=30,红色=31,绿色=32,黄色=33,蓝色
echo -e "\e[1;42m 背景颜色设置: 重置=0,黑色=40,红色=41,绿色=42,黄色=43,蓝色
echo "color set: --> [ echo -e \"\e[1;31m This is red text \e[0m\" ]"
echo -e "\e[1;31m This is red text \e[0m"
echo -e "\e[1;4;42m 加粗,开启下划线,背景色绿色 \e[0m"
echo "----------> \e[1;4;42m 加粗,开启下划线,背景色绿色 \e[0m"
echo "another format: \033[1;4;32m <--start \[data\] end--> \033[0m"
echo -e "another format: \033[1;4;32m <--start \[data\] end--> \033[0m
~
~