I used termcolor to print a colored text which ended up printing a weird code in Powershell, thus I used colorama.init() but it didn't change anything. I copied and texted some other code from Stackoverflow as I failed to import colorama at the beginning.
import sys
from termcolor import colored
if sys.platform == 'win32':
try:
import colorama
except ImportError:
pass
else:
colorama.init()
text = colored("HI THERE!", color="magenta", on_color="on_cyan", attrs=["blink"])
print(text)
This codes prints out a colored message in Powershell (it doesn't blink though). However I don't know why this shorter code doesn't work. (It prints "[5m[46m[35mHI THERE![0m")
from termcolor import colored
import colorama
colorama.init()
text = colored("HI THERE!", color="magenta", on_color="on_cyan", attrs=["blink"])
print(text)
I do import termcolor and colorama; and use init, colored methods in both these codes but I don't know why it only works with the first code. Do you know what might be the reason behind this? Thanks in advance.