print("hello")
The output should be the word "hello", but underlined.
You can do it by using escape characters.
print("\033[4mhello\033[0m")
Struggled with this issue for a bit, and in my case the problem was the line 'colorama.init(autoreset=True)'. For some reason, it looks like in Python3 Windows, if you use the Colorama autoreset, you can't print underlined text (you can still print bold text, with foreground, background colors, etc., so far I found that only the underline formatting is affected). Of course, that also means you would have to reset the text manually by adding the ANSI reset sequence ESC [0m
(in the example below, that would be the \033[0m
at the end of the print statement).
import colorama
#colorama.init(autoreset=True) #This line was causing me problems
#import os #To use below line
#os.system("") #This line can make it work in some terminals
print("\033[1;4mBold and underlined text\033[0m")
Some additional notes, after some more testing:
os.system("")
line before the print statement can make it work. I tested this on cmd, and it worked (line colorama.init(autoreset=True)
still commented).EDIT: Added 'import colorama' line and additional notes for completeness
You may type
print("\u0332".join("hello ")) enter image description here
string = 'Hello world'
emptystring = ''
for i in range(0, len(string)):
if string[i] == ' ':
emptystring = emptystring + string[i]
else:
emptystring= emptystring+string[i]+str('\u0332')
print(emptystring)
make sure you have python3 interpreter then run
x="the solution"
print("\033[4m" + x + "\033[0m")
Make sure you have Python 3.6+ Install quo using pip https://pypi.org/project/quo
from quo import echo
echo(f"Hello World!!!", underline=True)