How to make text italic in python



i heard of code to make text bold or underlined, but is there code to make text italics?

here's the code that i saw

class color:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
END = '\033[0m'

print color.BOLD + 'Hello World !' + color.END


As far as Python is concerned, that's just text. But yes, some terminal emulators support italics, the escape sequence for that is \e[3m

There are some packages for colorizing output, I did a quick google search and there's one called "colorama" which is supposedly cross-platform so that's probably a good start.

colorama can be installed with pip, and there are some demo files in its source:


found an article on
that may be of interrest to you

google search
== discussions / opinions ==
how determine the terminal type in python


i forgot to actaully mention my final intent. i wish to copy the output and be able to paste it in word (already got that sorted but it isnt italic). is there some way in which the copied text was turned into italics or just some fancy formatting option?


There's a package for editing docx files, dealing with some clipboard-application/the OS sounds very platform-dependent and a bunch of extra challenges.
python-docx is a Python library for creating and updating Microsoft Word (.docx) files.