2016-11-24 25 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() 

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