V
V
VuztreeCalan2018-10-14 11:15:09
Python
VuztreeCalan, 2018-10-14 11:15:09

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')

5bc2faaf1ea72420610601.png
5bc2f9d4af624036831503.png

# 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

1 answer(s)
S
Sergey Gornostaev, 2018-10-14
@VuztreeCalan

The fact that Colorama does not work with inputPython 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 printfor output , and the function uses a WinAPI call that does not understand control sequences. writestdoutinputWriteConsoleW

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question