Bottom Page

Thread Rating:
  • 2 Vote(s) - 1.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
colorama/termcolor not returning coloured lines
#1
Code -
from colorama import Fore, Back, Style
print(Fore.RED + 'some red text')
print(Back.GREEN + 'and with a green background')
print(Style.DIM + 'and in dim text')
print(Style.RESET_ALL)
print('back to normal now')
output -
Output:
[31msome red text [42mand with a green background [2mand in dim text[0m back to normal now
I used colorama library to change the font colour of few words. Unfortunately, it is not returning any lines with their respective colors. Can anyone help me to identify the issue?. Thanks in advance
buran wrote Jan-14-2019, 12:40 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
You like this post
Quote
#2
where do you run this code? you need to run it from command prompt/terminal. I guess you run it in IDE...
You like this post
Quote
#3
(Jan-14-2019, 12:43 PM)buran Wrote: where do you run this code? you need to run it from command prompt/terminal. I guess you run it in IDE...
I did run it in IDLE. I also ran it in command prompt/terminal and it is still giving the same output. I read somewhere that my PC color codes has to match with python color codes and something to do with ANSI color code mismatch. Do you know anything about that?
Thank you
You like this post
Quote
#4
On windows you need to call init(). On other platforms it's simply ignored if present

from colorama import Fore, Back, Style, init
init()
print(Fore.RED + 'some red text')
print(Back.GREEN + 'and with a green background')
print(Style.DIM + 'and in dim text')
print(Style.RESET_ALL)
print('back to normal now')
run this from cmd, not in IDLE
You like this post
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  problem returning values Naito 7 130 Jan-19-2019, 08:21 PM
Last Post: Naito
  Function not returning correct value ActualNoob 3 123 Jan-11-2019, 12:35 AM
Last Post: stullis
  Format text and variables - more lines dan789 3 139 Jan-08-2019, 03:07 PM
Last Post: buran
  grep command based on lines in a pattern file Skaperen 1 94 Jan-07-2019, 10:23 AM
Last Post: Gribouillis
  Executing 2 lines at the same time SheeppOSU 2 124 Dec-22-2018, 05:16 AM
Last Post: Gribouillis
  Returning true or false in a for loop bbop1232012 3 139 Nov-22-2018, 04:44 PM
Last Post: bbop1232012
  edit text files/ add lines if missing (regex) wardancer84 3 188 Nov-08-2018, 02:47 PM
Last Post: wardancer84
  Best replacement for pyzmail in lines 15 and 16 Pedroski55 0 147 Nov-03-2018, 06:12 AM
Last Post: Pedroski55
  2 lines causing code failure sfadil 5 234 Oct-26-2018, 09:58 AM
Last Post: sfadil
  LDAP code to query for host not returning data burvil 2 246 Oct-17-2018, 10:03 PM
Last Post: burvil

Forum Jump:


Users browsing this thread: 1 Guest(s)