我是新来的蟒蛇(大约一周或更少),我使用python 2.7。如何使用python制作颜色输出?
我正在写一个程序来检查IP验证和类,我想在颜色的输出,所以它会更可读的终端给用户。
我已经尝试过这样的:
# to make the text purple for example.
print '\033[95m' + "This is a purple output"
# if i'm writing another simple print after the first one it will be purple too
print "Example" # now this statement purple too
但是当我使用这个例子中,输出后的第一个印刷方法变紫了。
感谢所有尝试的人。
你可以这样做:print'\ 033 [95m'+“这是一个紫色的输出”+'\ 033'0' –
ohh我没看到那个帖子。对不起 – shemesh