0

I'm trying to get a text blink in python . I found this method:

from termcolor import colored, cprint
cprint('\nJames Everleigh', 'red', attrs=['blink'])

but when i compile it i get some sort weird text:

""[5m[31m
James Everleigh[0m ""

What do I need to use to get the desired output?

HelgeFox
  • 349
  • 2
  • 13
  • What OS are you using? – khelwood May 22 '18 at 13:51
  • Possible duplicate of [Why does termcolor output control characters instead of colored text in the Windows console?](https://stackoverflow.com/questions/21858567/why-does-termcolor-output-control-characters-instead-of-colored-text-in-the-wind) – khelwood May 22 '18 at 13:55

2 Answers2

0

[5m[31m and [0m are are ANSI escape codes for format and color. You have to enable your terminal to interpret them.

toliveira
  • 1,533
  • 16
  • 27
  • @TibiGhimbas What terminal emulator are you using? In many terminals blinking is just bright or bold text. – mx0 May 22 '18 at 19:13
0

if you are using windows powershell you need to pip colorama and import init from colorama and run it like this:

from colorama import init
from termcolor import colored
init()
print(colored("text","red"))
dboy
  • 1,004
  • 2
  • 16
  • 24
dieshell
  • 1
  • 1