R
R
Roman Komyagin2020-08-20 05:38:07
Python
Roman Komyagin, 2020-08-20 05:38:07

How to use the colorama library to make input text with a colored background without extra characters?

import colorama
from colorama import init
from colorama import Fore, Back, Style
init()

q = input('Введите пароль: ' + Fore.GREEN + Back.RED )


I tried to enter Fore and Back after the quotes, but in the output this is it and the input text is not highlighted
Output:
Enter password: ?[32m?[41m

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
yaloh, 2020-08-20
@BloomEe

Krch here, keep the code with comments

import colorama # Импортируем модуль.
from colorama import init
from colorama import Fore, Back, Style
init()
print(Fore.GREEN + Back.RED) # Вот тута указываем цвета.
q = input('Введите пароль: ') # Далее, просто запрашиваем пароль.

A
Alexander, 2020-08-20
@shabelski89

First, the console parameters are set, then the text.

import colorama
from colorama import Fore, Back, Style
colorama.init()
q = input(Fore.GREEN + Back.RED + 'Введите пароль: ')
print(Back.GREEN + Fore.RED + q)

5f3de7d395414350281328.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question