Output is not coming with defined color

A

Avnesh Shakya

hi,
I am trying to display my output with different colour on terminal, but it's
coming with that colour code.
Please help me how is it possible?

my code is -
from fabric.colors import green, red, blue
def colorr():
a = red('This is red')
b = green('This is green')
c = blue('This is blue')
d = {a, b, c}
print d
colorr()

output -
set(['\x1b[32mThis is green\x1b[0m', '\x1b[34mThis is blue\x1b[0m', '\x1b[31mThis is red\x1b[0m'])

Thanks
 
F

Fábio Santos

hi,
I am trying to display my output with different colour on terminal, but it's
coming with that colour code.
Please help me how is it possible?

my code is -
from fabric.colors import green, red, blue
def colorr():
a = red('This is red')
b = green('This is green')
c = blue('This is blue')
d = {a, b, c}
print d
colorr()

output -
set(['\x1b[32mThis is green\x1b[0m', '\x1b[34mThis is blue\x1b[0m', '\x1b[31mThis is red\x1b[0m'])

Thanks

You are printing the {a, b, c} set. That ends up printing the repr of all
of its contents. The repr breaks the desired output. Try to just

print a, b, c
 
R

rusi

hi,
   I am trying to display my output with different colour on terminal, but it's
coming with that colour code.
Please help me how is it possible?
my code is -
from fabric.colors import green, red, blue
def colorr():
    a = red('This is red')
    b = green('This is green')
    c = blue('This is blue')
    d = {a, b, c}
    print d
colorr()
output -
set(['\x1b[32mThis is green\x1b[0m', '\x1b[34mThis is blue\x1b[0m',

'\x1b[31mThis is red\x1b[0m'])



You are printing the {a, b, c} set. That ends up printing the repr of all
of its contents. The repr breaks the desired output. Try to just

print a, b, c

Or

for x in d: print x
should work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top