Original: os.system("echo \u001b[31mU have Been Hacked").
And I have tried print(u"")
, print()
but nothing works and I don't want to install any libraries so can someone help me?
Original: os.system("echo \u001b[31mU have Been Hacked").
And I have tried print(u"")
, print()
but nothing works and I don't want to install any libraries so can someone help me?
Use colorama library.
import colorama
# Init allows color printing on windows terminals
# and autoreset resets to default color after each print
colorama.init(autoreset=True)
print(colorama.Fore.Green + "Hello world!")
So this is without installing any libraries my implementation is
import os
def printWhiteOnRed(s):
os.system("echo |set /p out=\u001b[97;101m")
print(s)
os.system("echo |set /p out=\u001b[0m")
s= "you have done well"
printWhiteOnRed(s)
|set /p out=
This is to supress line ending in the command prompt, see this Stack Overflow answer.
\u001b
This is the ANSI escape character
[97;101m
This are the colours for white foreground on red background.
[0m
This is the reset code to ensure any further output is in normal style
Sources: Stackoverflow github