x = input('Name: \u001b[1m') # anything from here on will be BOLD
print('\u001b[0m', end='') # anything from here on will be normal
print('Your input is:', x)
\u001b[1m告诉终端切换到粗体文本。\u001b[0m告诉它重置。 This page很好地介绍了ANSI转义序列。
from colorama import init,Style,Fore,Back
import os
os.system('cls')
def inputer(prompt) :
init()
print(Style.NORMAL+prompt + Style.BRIGHT+'',end="")
x = input()
return x
## -------------------------
inputer("Input your name: ")
2条答案
按热度按时间w7t8yxp51#
它们被称为ANSI转义序列。基本上你输出一些特殊的字节来控制终端文本的外观。试试这个:
\u001b[1m
告诉终端切换到粗体文本。\u001b[0m
告诉它重置。This page很好地介绍了ANSI转义序列。
j0pj023g2#
You can do the following with colorama:
and the output will be as follows:
Input your name: John
ref. : https://youtu.be/wYPh61tROiY