Python Forum
Change Text Color Output in Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Change Text Color Output in Python
#1
I'm trying to change the output text to green and the background to blue using this code:

    print("\033[1;32;44m******************************************************")
    print("\033[1;32;44m* Terminate Instance Operations in AWS Are Complete. *")
    print("\033[1;32;44m******************************************************")
But the output is the the default powershell white and the numeric codes are visible. This is how the output looks:

Error:
[1;32;44m****************************************************** [1;32;44m* Terminate Instance Operations in AWS Are Complete. * [1;32;44m******************************************************
What am I doing wrong?
Reply
#2
Those look like ansi color escapes, which don't work on windows afaik.
If you need a cross-platform way to display colored output, you should take a look at colorama.
Reply
#3
(Mar-04-2019, 07:56 PM)stranac Wrote: Those look like ansi color escapes, which don't work on windows afaik.
If you need a cross-platform way to display colored output, you should take a look at colorama.


Thanks! I got colorization of my python scripts text output to work on windows and linux with Colorama! Good stuff! I appreciate the tip!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] Change Text Size in Console? CodingKid 1 334 Jul-20-2021, 02:47 PM
Last Post: deanhystad
  extract color text from PDF Maha 0 407 May-31-2021, 04:05 PM
Last Post: Maha
Question Text color (ascii) in a dictionary banidjamali 1 515 Feb-24-2021, 06:03 PM
Last Post: deanhystad
  Getting a GET request output text into a variable to work with it. LeoT 2 585 Feb-24-2021, 02:05 PM
Last Post: LeoT
  Increment text files output and limit contains Kaminsky 1 852 Jan-30-2021, 06:58 PM
Last Post: bowlofred
  How to Split Output Audio on Text to Speech Code Base12 2 3,751 Aug-29-2020, 03:23 AM
Last Post: Base12
  change a text file Blue Dog 5 1,046 Aug-04-2020, 05:51 AM
Last Post: DeaD_EyE
  Change the color automatically Dragonos 5 1,178 Jul-28-2020, 01:17 PM
Last Post: Dragonos
  Use of input function to change screen background color in Turtles Oldman45 3 1,804 Jul-10-2020, 09:54 AM
Last Post: Oldman45
  Change Text Size in Console? ShakeyPakey 8 4,459 Jun-03-2020, 08:48 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020