2014-10-09 138 views
0

我有一个包含python代码的python文件名test.py。使用python脚本更改python文件中的字体颜色

print "THIS IS TEST" 
print "THIS IS GOOD" 
print "THIS IS BAD" 

我想换行的字体\颜色或背景在任何编辑器

print "THIS IS GOOD" 

我怎么能这样做?

如果它的编辑器具体,哪个编辑器允许我使用代码对文件本身进行这样的更改? IDLE,Eclipse,Notepad ++或其他?

请让我知道任何编辑器及其脚本示例,通过它我可以在其中更改线来查看这样更改的文件。

我不想印刷在终端。我需要在ECLIPSE,NOTEPAD ++或IDLE中突出显示行/更改字体。

回答

1

Print in terminal with colors using Python?

这个问题会有所帮助。

一个例子:

print '\033[94m'+"THIS IS GOOD"+'\033[0m' 

既然你引用的 “记事本++”,我想你在Windows上运行。所以,试试这个:

Change shell print color in python 3.3.2

from subprocess import call 

call('color a', shell=True) #this sets the color to light green 
print('The quick brown fox jumps over the lazy dog.') 
+0

我想要的颜色应该是notepadd ++变化,而不是外壳。我需要在编辑器中更改color \ font以供查看。 – sam 2014-10-09 04:33:55