Answer the question
In order to leave comments, you need to log in
How to explain the difference in text processing inside print and input, when launched via CMD?
A lyrical digression - I wanted to decorate the program a little with colored symbols in the console, googled about the colorama and termcolor modules, tested it, at first glance everything was fine, everything is output, but then I noticed strange things if you run the program not through the IDE (Everything works there), but through CMD:
There is the following element:
And if I put it in print, then everything will work, and if I put it in input, I will see the text designation of the color, that’s crocozyabry IDE CMD
So, people who understand, please explain to yellowmouth why CMD processes text inside input differently and print?
P.S. Whole code:attentionSign = colored("[!]", 'red')
# coding: utf8
from colorama import init
from termcolor import colored
init()
attentionSign = colored("[!]", 'red')
print("Цветной символ внутри print:")
print(attentionSign)
print("Цветной символ внутри input")
input(attentionSign)
Answer the question
In order to leave comments, you need to log in
The fact that Colorama does not work with input
Python 3.5 and above is a reported bug , which is the result of a Python bug . In short, the function uses a C function with a descriptor print
for output , and the function uses a WinAPI call that does not understand control sequences. write
stdout
input
WriteConsoleW
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question