0

when use this code:

from termcolor2 import colored

print(colored('hello', 'red'), colored('world', 'green'))

my output in terminal is :←[31mhello←[0m ←[32mworld←[0m

whats the problem?

Michael Butscher
  • 10,028
  • 4
  • 24
  • 25
dark diamond
  • 103
  • 6
  • answered here https://stackoverflow.com/questions/21858567/why-does-termcolor-output-control-characters-instead-of-colored-text-in-the-wind -- you need colorama module and colorama.init() – Aaj Kaal Dec 22 '20 at 03:12

1 Answers1

1

You can use colorama module

pip install colorama

Code:

from colorama import init, Fore, Back

init(convert=True)    # Initialize colorama module
print(Fore.RED + 'Your Text' + Fore.RESET)    # Red colored output
print(Back.GREEN + 'Your Text' + Back.RESET)  # Green Backgroung Output

More Details - https://pypi.org/project/colorama/

Hirusha Fernando
  • 1,156
  • 10
  • 29