I have a small game application, which is started from the Windows console (cmd.exe). I am able to format the text in any desired way using ANSI escape sequences.
I would also love to apply formatting to the text from the input()
-method, but I have not found a way how to do so. Here is the testing code...
from colorama import init
init(autoreset=True)
RED = "\x1b[1;31;40m"
print(f"{RED}This text is red\n")
not_red = input(f"{RED}Insert some random stuff: ")
in my windows console, you will see that the ANSI sequence is displayed as a simple string in the input statement:
whereas in my Spyder IDE console, it has the reverse effect:
Can anyone explain the displayed behaviour in the different consoles to me?
And is there any way to format the input()
-text in the Windows cmd console? This is where my program is run normally and I would like to make it even prettier :-)
Thanks in advance!