2016-11-24 70 views
0

我是编程新手,所以我为愚蠢的问题道歉。我在Windows上使用Python 3.5.2。PyShell python中的颜色变化对我不起作用

我想打印在我pyShell颜色,因为作为一个newbee,多数民众赞成在那里我学会了编写...我不明白为什么YouTube上的所有的例子都是在Windows命令提示符

反正我安装彩色光

代码:

from colorama import Fore, Back, Style 
print(Fore.RED + 'some red text') 
print(Back.GREEN + 'and with a green background') 
print(Style.DIM + 'and in dim text') 
print(Style.RESET_ALL) 
print('back to normal now') 

和我PyShell我得到......奇怪的字符和代码全部为蓝色。 例如:

[31msome red text 
[42mand with a green background 
[2mand in dim text 
[0m 
back to normal now 

请帮助,否则我将刹车我的电脑。 ..thanks ...笑

+0

IDLE的PyShell是一个开发shell,而不是终端模拟器。使用python.exe交互式shell。这是一个Windows控制台应用程序,它支持colorama。 – eryksun

回答

0

则需要使用初始化COLORAMA:

from colorama import init 
init() 

,一切工作正常您的代码。