-2

I have been looking for an answer to this for ages, but no sites seem to help at all. There are various questions on the site explaining how to change the colour of the python terminal output text, but it does not work for more recent versions (python 3 onwards).

Is there still a way to change output text? I'd rather not change the colour of the entire terminal, but instead just a few lines, which would be simple print() commands.

  • It is very important to mention the OS you're on. Windows for example has very limited support for this and requires trickery to work. Posix often just works by outputting the proper ANSI escape sequences. – Irmen de Jong Dec 05 '16 at 19:04
  • Oh sorry, I'm working on Windows 10 unfortunately – Meme Meister Dec 05 '16 at 20:46
  • Possible duplicate of [How to print colored text in terminal in Python?](https://stackoverflow.com/questions/287871/how-to-print-colored-text-in-terminal-in-python) – Nazim Kerimbekov Apr 30 '19 at 21:41

1 Answers1

0

Because you're on Windows, a lot of terminal color packages won't work. Many depend on the terminal capabilities of a Posix system. That said, there are a few that have some Windows compatibility. I've had moderate success myself with colorama.

>>> import colorama
>>> colorama.init()
>>> print(colorama.Fore.GREEN+"GREEN"+colorama.Fore.RESET+"normal")
GREENnormal
>>>   # 'GREEN' above is printed in green.
Irmen de Jong
  • 2,739
  • 1
  • 14
  • 26