Python colorama not working with input?

Finally, colorama works today, and it works great when printing lines, but I got a general error that everyone seems to get when I tried to use colorama with input.

Here is my code:

launch = input(Fore.GREEN + "Launch attack?(Y/N): ") 

Screenshot:

enter image description here

+5
source share
1 answer

On my system, input() works with colors if you add

 import sphinx.quickstart 

to your module.

So here is the complete code.

 from colorama import Fore import colorama import sphinx.quickstart colorama.init() launch = input(Fore.GREEN + "Launch attack? (Y/N): ") 

(This leads to two questions:

  • Why does this not work in the first place?
  • What is the reason? - Someone might want to dive into the sphinx source code.)

<i> NB if you run python via winpty from Git Bash , install convert .

 colorama.init(convert=True) 

Otherwise, you will not get the color with current versions.

+3
source

Source: https://habr.com/ru/post/1232645/


All Articles