Underlining is a function of the program that is displaying it. You would have to look at how the particular IDE or word-processor you are using does it. If you want to print on a printer, you would have to use your printer's control language or a markup language like postscript or HTML. Python can do all of this but you have to tell it what underline means for your particular application.
Comment