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
  How to re run lines in python? MrDoggo124 1 69 Mar-06-2019, 07:25 PM
Last Post: Yoriz
  Two lines of code at the same time? OTO1012 1 66 Mar-04-2019, 05:32 PM
Last Post: ichabod801
  Need help - 22000 lines of code / alien writings! gfetng 1 107 Feb-22-2019, 03:25 PM
Last Post: ichabod801
  using vars from one file to match lines in another gt76_noobster 3 167 Jan-30-2019, 05:34 PM
Last Post: ichabod801
  problem returning values Naito 7 220 Jan-19-2019, 08:21 PM
Last Post: Naito
  Function not returning correct value ActualNoob 3 197 Jan-11-2019, 12:35 AM
Last Post: stullis
  Format text and variables - more lines dan789 3 230 Jan-08-2019, 03:07 PM
Last Post: buran
  grep command based on lines in a pattern file Skaperen 1 157 Jan-07-2019, 10:23 AM
Last Post: Gribouillis
  Executing 2 lines at the same time SheeppOSU 2 198 Dec-22-2018, 05:16 AM
Last Post: Gribouillis
  Returning true or false in a for loop bbop1232012 3 223 Nov-22-2018, 04:44 PM
Last Post: bbop1232012

Forum Jump:


Users browsing this thread: 1 Guest(s)