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
  Turtle Star Fill Color Yellow-White Interchanging Color Effect codelab 9 900 Oct-25-2023, 09:09 AM
Last Post: codelab
  output values change akbarza 3 487 Oct-18-2023, 12:30 PM
Last Post: deanhystad
  Find a specific keyword after another keyword and change the output sgtmcc 5 746 Oct-05-2023, 07:41 PM
Last Post: deanhystad
  Color a table cell based on specific text Creepy 11 1,824 Jul-27-2023, 02:48 PM
Last Post: deanhystad
  ANSI not working for change of text colors BliepMonster 10 3,245 Nov-10-2022, 09:28 AM
Last Post: BliepMonster
  simplekml change shape&color issac_n 2 2,772 Aug-20-2022, 07:15 PM
Last Post: Joseph_Paintsil
  find some word in text list file and a bit change to them RolanRoll 3 1,482 Jun-27-2022, 01:36 AM
Last Post: RolanRoll
  Rain sensor output only on change Pete6 3 1,983 May-11-2022, 10:36 PM
Last Post: Pete6
Photo Visual studio code unable to color syntax on python interpreter tomtom 4 6,680 Mar-02-2022, 01:23 AM
Last Post: tomtom
  Search text in PDF and output its page number. atomxkai 21 8,672 Jan-21-2022, 06:20 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

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