Python Forum

Full Version: How to display <IPython.core.display.HTML object>?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I am using Python 3.6.5.

When I run the following code,
from IPython.display import display, HTML

display(HTML('<h1>Hello, world!</h1>'))


I only get: <IPython.core.display.HTML object>

Do I miss something? Wall
(Oct-16-2018, 08:47 PM)pythopen Wrote: [ -> ]Do I miss something?
Yes Jupyter Notebook
You can only render HTML in a browser,and not in a Python console/editor environment.
Can call .data to see html,but it will not render.
In [17]: from IPython.display import display, HTML

In [18]: display(HTML('<h1>Hello, world!</h1>').data)
'<h1>Hello, world!</h1>'
Rich Output examples in Jupyter Notebook.
Got it. Thank you.
(Oct-17-2018, 12:34 AM)snippsat Wrote: [ -> ]
(Oct-16-2018, 08:47 PM)pythopen Wrote: [ -> ]Do I miss something?
Yes Jupyter Notebook
You can only render HTML in a browser,and not in a Python console/editor environment.
Can call .data to see html,but it will not render.
In [17]: from IPython.display import display, HTML

In [18]: display(HTML('<h1>Hello, world!</h1>').data)
'<h1>Hello, world!</h1>'
Rich Output examples in Jupyter Notebook.

Thanks for sharing this info