colorama
colorama copied to clipboard
Unexpected background color rendered in terminal
import colorama
from contextlib import contextmanager
b = "type: <\x1b[39m\x1b[38;5;100mclass\x1b[39m\x1b[38;5;245m \x1b[39m\x1b[38;5;166m'\x1b[39m\x1b[38;5;32mdict\x1b[39m\x1b[38;5;36m'\x1b[39m\x1b[38;5;36m>\x1b[39m"
@contextmanager
def supportTerminalColorsInWindows():
colorama.init()
yield
colorama.deinit()
print(b)
with supportTerminalColorsInWindows():
print(b)
Running the above code gives an unexpected result shown below on both PowerShell and CMD.