Bottom Page

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?
Quote
#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.
bluethundr likes this post
Quote
#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!
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Four text files input combinations into an output file mhyga 2 317 Jul-28-2019, 06:52 PM
Last Post: ThomasL
  Save console output to text file (like a log) koticphreak 9 1,177 Jun-02-2019, 07:45 PM
Last Post: snippsat
  Python function call font color JeffR1992 1 530 Apr-17-2019, 06:38 AM
Last Post: perfringo
  eric6 IDE no output into text file daveq 5 584 Mar-22-2019, 11:31 PM
Last Post: daveq
  modify the color a string of characters in python 3.6 atlass218 10 961 Feb-28-2019, 03:20 PM
Last Post: atlass218
  Saving python cmd output into a text file with colours kapilan15 2 525 Jan-25-2019, 06:25 PM
Last Post: metulburr
  Confusing output from 2to3 about what files need change Moonwatcher 1 930 Dec-30-2018, 04:07 PM
Last Post: Gribouillis
  Randomizing Color Output ammorgan 0 410 Dec-27-2018, 03:31 AM
Last Post: ammorgan
  Change output of cells. Hoogoo 2 525 Nov-19-2018, 12:47 AM
Last Post: Larz60+
  Is there a way to detect the text font, size and color from an image in python? Maia07 2 1,434 Aug-23-2018, 01:16 PM
Last Post: Maia07

Forum Jump:


Users browsing this thread: 1 Guest(s)