Example 1: print colored text python
def colored(r, g, b, text): return "\033[38;2;{};{};{}m{} \033[38;2;255;255;255m".format(r, g, b, text) text = 'Hello, World' colored_text = colored(255, 0, 0, text) print(colored_text) print(colored(255, 0, 0, 'Hello, World'))
Example 2: ansi colors
Black \e[0;30m Blue \e[0;34m Green \e[0;32m Cyan \e[0;36m Red \e[0;31m Purple \e[0;35m Brown \e[0;33m Gray \e[0;37m Dark Gray \e[1;30m Light Blue \e[1;34m Light Green \e[1;32m Light Cyan \e[1;36m Light Red \e[1;31m Light Purple \e[1;35m Yellow \e[1;33m White \e[1;37m
Example 3: python ansi escape sequences color collection
class colors: reset = "\033[0m" fgBlack = "\033[30m" fgBrightBlack = "\033[30;1m" bgBlack = "\033[40m" bgBrightBlack = "\033[40;1m" fgRed = "\033[31m" fgBrightRed = "\033[31;1m" bgRed = "\033[41m" bgBrightRed = "\033[41;1m" fgGreen = "\033[32m" fgBrightGreen = "\033[32;1m" bgGreen = "\033[42m" bgBrightGreen = "\033[42;1m" fgYellow = "\033[33m" fgBrightYellow = "\033[33;1m" bgYellow = "\033[43m" bgBrightYellow = "\033[43;1m" fgBlue = "\033[34m" fgBrightBlue = "\033[34;1m" bgBlue = "\033[44m" bgBrightBlue = "\033[44;1m" fgMagenta = "\033[35m" fgBrightMagenta = "\033[35;1m" bgMagenta = "\033[45m" bgBrightMagenta = "\033[45;1m" fgCyan = "\033[36m" fgBrightCyan = "\033[36;1m" bgCyan = "\033[46m" bgBrightCyan = "\033[46;1m" fgWhite = "\033[37m" fgBrightWhite = "\033[37;1m" bgWhite = "\033[47m" bgBrightWhite = "\033[47;1m"
Comments
Post a Comment