mirror of
https://github.com/Aroy-Art/Learning-Python.git
synced 2024-12-26 05:56:40 +01:00
Added a class of colors for printing text
This commit is contained in:
parent
e04c2b9590
commit
5b01c66296
1 changed files with 44 additions and 0 deletions
44
Class-of-colors.py
Normal file
44
Class-of-colors.py
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
# Python program to print
|
||||||
|
# colored text and background
|
||||||
|
class colors:
|
||||||
|
#Colors class:reset all colors with colors.reset; two
|
||||||
|
#sub classes fg for foreground
|
||||||
|
#and bg for background; use as colors.subclass.colorname.
|
||||||
|
#i.e. colors.fg.red or colors.bg.greenalso, the generic bold, disable,
|
||||||
|
#underline, reverse, strike through,
|
||||||
|
#and invisible work with the main class i.e. colors.bold
|
||||||
|
reset='\033[0m'
|
||||||
|
bold='\033[01m'
|
||||||
|
disable='\033[02m'
|
||||||
|
underline='\033[04m'
|
||||||
|
reverse='\033[07m'
|
||||||
|
strikethrough='\033[09m'
|
||||||
|
invisible='\033[08m'
|
||||||
|
class fg:
|
||||||
|
black='\033[30m'
|
||||||
|
red='\033[31m'
|
||||||
|
green='\033[32m'
|
||||||
|
orange='\033[33m'
|
||||||
|
blue='\033[34m'
|
||||||
|
purple='\033[35m'
|
||||||
|
cyan='\033[36m'
|
||||||
|
lightgrey='\033[37m'
|
||||||
|
darkgrey='\033[90m'
|
||||||
|
lightred='\033[91m'
|
||||||
|
lightgreen='\033[92m'
|
||||||
|
yellow='\033[93m'
|
||||||
|
lightblue='\033[94m'
|
||||||
|
pink='\033[95m'
|
||||||
|
lightcyan='\033[96m'
|
||||||
|
class bg:
|
||||||
|
black='\033[40m'
|
||||||
|
red='\033[41m'
|
||||||
|
green='\033[42m'
|
||||||
|
orange='\033[43m'
|
||||||
|
blue='\033[44m'
|
||||||
|
purple='\033[45m'
|
||||||
|
cyan='\033[46m'
|
||||||
|
lightgrey='\033[47m'
|
||||||
|
|
||||||
|
print(colors.fg.blue, "SKk", colors.fg.purple, "Amartya", colors.reset)
|
||||||
|
print("SKk", colors.fg.red, "Amartya", colors.reset)
|
Loading…
Reference in a new issue