Answers for "how to print red text in python"

0

print red in python

import os

# System call
os.system("")

# Class of different styles
class style():
    BLACK = '33[30m'
    RED = '33[31m'
    GREEN = '33[32m'
    YELLOW = '33[33m'
    BLUE = '33[34m'
    MAGENTA = '33[35m'
    CYAN = '33[36m'
    WHITE = '33[37m'
    UNDERLINE = '33[4m'
    RESET = '33[0m'

print(style.YELLOW + "Hello, World!")
Posted by: Guest on February-27-2021
2

add colour to text in python

def colored(r, g, b, text):
    return "33[38;2;{};{};{}m{} 33[38;2;255;255;255m".format(r, g, b, text)
  
text = 'Hello, World'
colored_text = colored(255, 0, 0, text)
print(colored_text)

#or

print(colored(255, 0, 0, 'Hello, World'))
Posted by: Guest on October-31-2020

Python Answers by Framework

Browse Popular Code Answers by Language