Paul Moore added the comment:
This works fine for me in Windows terminal, but I see the behaviour described
when using the conventional "Command prompt" window.
Enabling ANSI codes is handled via SetConsoleMode (see here:
https://docs.microsoft.com/en-us/windows/console/setconsolemode). The
New submission from Dave Rove :
The correct handling of ANSI escape codes by the print() function may or may
not be enabled in the Windows 10 command prompt window, depending on previous
system calls. The following is quite repeatable. Comment-out the apparently
meaningless os.system("") line