I have a python program where I am trying to print "Hello" in colored text using ANSI codes in command prompt. When I print in normally, it is not working, it just prints ? and text, but when I print it after clearing the command prompt it works fine. Can some one explain this weird nature.
I searched for this but couldn't find anything about this nature. I am using Windows 10
The below code outputs [0;32mHello[0m
print('\x1b[0;32m' + "Hello" + '\033[0m')
whereas the below code outputs Hello in green color.
os.system("cls")
print('\x1b[0;32m' + "Hello" + '\033[0m')
Right image is the output of the code shown above or in the left image
My expectation was that is gives either ansii or colored text in both the above codes, but actual output is different in both the cases