所以我正在ubuntu上进行python3项目,我需要彩色文本,并且通过快速的Google搜索,我发现bcolors满足了我的需要。唯一的问题是,当我将其与input()
一起使用时,它永远不会换行,而只是在自身之上编写。
这是bcolors:
class bcolors:
purple = '\033[95m'
blue = '\033[94m'
green = '\033[92m'
yellow = '\033[93m'
red = '\033[91m'
cyan = '\033[96m'
white = '\033[97m'
grey = '\033[90m'
end = '\033[0m'
bold = '\033[1m'
underline = '\033[4m'
示例:
输入
while True:
x = input('{}input {}'.format(bcolors.green, bcolors.end))
print(x)
第一行空间不足时:
oddut it is really odd it is really odd it is really odd it is really
代替
input it is really odd it is really odd it is really odd it is really it is really odd