So fügen Sie Python -Text Farbe hinzu
# You can use colorama for changing the text color here is a example of that
from ast import For
from random import random
from random import randint
'''
First Install colorama by typing this in the terminal:
python -m pip install colorama or simply pip install colorama
'''
import colorama
from colorama import Fore,Back,Style
colorama.init(autoreset=True)
# Now here back is for background and Fore is for text color.
while(0<10):
eyt = input("Enter your text - ")
wcib= input("Enter your colour for back - ")
# wcib= wcib.upper()
wcif= input("Enter your colour for text - ")
# wcif= wcif.upper()
if(wcib == "black" and wcif == "red"):
print(Back.BLACK + Fore.RED + eyt)
if(wcib == "black" and wcif == "blue"):
print(Back.BLACK + Fore.BLUE + eyt)
else:
randoma=randint(1,6)
if(randoma == 1):
print(Back.BLACK+Fore.LIGHTGREEN_EX+"We are sorry we dont have that in our library")
if(randoma == 2):
print(Back.BLACK+Fore.LIGHTBLACK_EX+"We are sorry we dont have that in our library")
if(randoma == 3):
print(Back.BLACK+Fore.LIGHTCYAN_EX+"We are sorry we dont have that in our library")
if(randoma == 4):
print(Back.BLACK+Fore.LIGHTMAGENTA_EX+"We are sorry we dont have that in our library")
if(randoma == 5):
print(Back.BLACK+Fore.LIGHTRED_EX+"We are sorry we dont have that in our library")
if(randoma == 6):
print(Back.BLACK+Fore.LIGHTYELLOW_EX+"We are sorry we dont have that in our library")
'''
colors present -
Fore: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.
Back: BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, RESET.
Style: DIM, NORMAL, BRIGHT, RESET_ALL
'''
Chess kingdom