Reputation: 1126
I am trying to use f-strings
to print some parts of text in italic format.
Browsing the web for "python"+"print"+"italic"+"f-strings"
, I found these ANSI codes should do the work : '\x1B[3m'
and '\x1B[0m'
; although they don't :
print(f'\x1B[3m italic \x1B[0m' + f'not italic')
gives no italic output :
italic not italic
Am I missing some update?
My python version is 3.9.7 and I'm using Jupyter Notebook
.
Upvotes: 1
Views: 2335
Reputation: 1278
In Jupyter Notebooks, you can use
from IPython.display import Markdown, display
display(Markdown("normal *italic* normal"))
See printing bold, colored, etc., text in ipython qtconsole, https://stackoverflow.com/a/46934204/747202
Upvotes: 1