I am trying to get colored command line output. I was able to get colored Python console output using colorama with this:
from colorama import Fore
from colorama import Style
print(f'{Fore.GREEN}A')
print(f'{Fore.RED}B')
print('C')
print(f'{Style.RESET_ALL}D')
print('E')
This perfectly works inside the Python Console in PyCharm. However, if I run the program under Windows cmd. There is no color at all but the colorama text is just added without any effect:
←[32mA
←[31mB
C
←[0mD
E
Can I modify the code so that it also works in Windows cmd?
You'll need to add convert=True to your colorama init call:
from colorama import Fore, Style, init
init(convert=True)
print(f'{Fore.GREEN}A')
print(f'{Fore.RED}B')
print('C')
print(f'{Style.RESET_ALL}D')
print('E')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With