问题
I can print test1 in green and test2 in red in ipython :
print ('\033[92m' + "test1")
print ('\033[91m' + "test2")
But gives me the following error printed in white in the terminal :
[92mtest1
[91mtest2
回答1:
Windows terminal doesn't handle ansi coding for coloring text like other (vt100 compatible) terminals. If you want to be able to color your output in windows your best bet is likely going to be something like colorama, Ansicon or some other external program to handle colorizing output to the windows terminal.
来源:https://stackoverflow.com/questions/60218097/how-to-have-colored-text-displayed-after-converting-script-into-a-exe