Make a note of the colors when using Python's text color specification library colorama on Windows7 Cmder.
import colorama
from colorama import Fore, Back, Style
colorama.init(autoreset=True)
Specify when outputting characters to color the subsequent characters.
print("foo," + Fore.BLUE + "bar," + Back.RED + "baz")
↓
It's colored!
You can use the following: 16 colors except RESET
.
Fore.BLACK Fore.LIGHTBLACK_EX Fore.LIGHTMAGENTA_EX Fore.MAGENTA Fore.YELLOW
Fore.BLUE Fore.LIGHTBLUE_EX Fore.LIGHTRED_EX Fore.RED
Fore.CYAN Fore.LIGHTCYAN_EX Fore.LIGHTWHITE_EX Fore.RESET
Fore.GREEN Fore.LIGHTGREEN_EX Fore.LIGHTYELLOW_EX Fore.WHITE
Back.BLACK Back.LIGHTBLACK_EX Back.LIGHTMAGENTA_EX Back.MAGENTA Back.YELLOW
Back.BLUE Back.LIGHTBLUE_EX Back.LIGHTRED_EX Back.RED
Back.CYAN Back.LIGHTCYAN_EX Back.LIGHTWHITE_EX Back.RESET
Back.GREEN Back.LIGHTGREEN_EX Back.LIGHTYELLOW_EX Back.WHITE
Style.BRIGHT Style.DIM Style.NORMAL Style.RESET_ALL
colorful!
The style is sober. DIM and NORMAL were no different.
Snippets to line up the above color samples.
#color
for attr in dir(Fore):
if attr[0] != '_':
print(getattr(Fore, attr) + "### Fore.{:<15}".format(attr) + Back.WHITE + "### Fore.{:<15}".format(attr))
print(getattr(Back, attr) + "### Back.{:<15}".format(attr) + Fore.BLACK + "### Back.{:<15}".format(attr))
#style
for attr in dir(Style):
if attr[0] != '_':
print(getattr(Style, attr) + "### Style.{:<10} ###".format(attr))
Recommended Posts