Python Forum
Text color (ascii) in a dictionary
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Text color (ascii) in a dictionary
#1
Question 
Hello everyone.

In this code:
spots = {1: '1', 2: '2', 3: '3'}
spots[1] = '\033[93mONE\033[0m'

print(spots[1])
print(spots)
why the color only applies to the first print line and the dictionary item does not read the color code?
Output:
ONE #this is colored(yellow) {1: '\x1b[93mONE\x1b[0m', 2: '2', 3: '3'}
I'm using VSCode on windows 10
Reply


Messages In This Thread
Text color (ascii) in a dictionary - by banidjamali - Feb-24-2021, 05:44 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Turtle Star Fill Color Yellow-White Interchanging Color Effect codelab 9 981 Oct-25-2023, 09:09 AM
Last Post: codelab
  Color a table cell based on specific text Creepy 11 1,934 Jul-27-2023, 02:48 PM
Last Post: deanhystad
  extract color text from PDF Maha 0 2,062 May-31-2021, 04:05 PM
Last Post: Maha
  Change Text Color Output in Python bluethundr 2 8,709 Mar-06-2019, 10:23 PM
Last Post: bluethundr
  Creating Dictionary form LOG /text file DG1234 7 5,438 Feb-13-2019, 08:08 PM
Last Post: DG1234
  Is there a way to detect the text font, size and color from an image in python? Maia07 2 8,645 Aug-23-2018, 01:16 PM
Last Post: Maia07
  Need help using pathlib to read text file into dictionary gwilli3 4 4,172 Aug-13-2018, 06:21 PM
Last Post: gwilli3
  unable to convert text file in dictionary purnima1 6 4,279 Apr-02-2018, 07:44 AM
Last Post: purnima1
  How to convert Text file contents into a dictionary. tannishpage 12 51,324 May-11-2017, 03:49 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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