Python Forum
How to display <IPython.core.display.HTML object>? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to display <IPython.core.display.HTML object>? (/thread-13473.html)



How to display <IPython.core.display.HTML object>? - pythopen - Oct-16-2018

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


RE: How to display <IPython.core.display.HTML object>? - snippsat - Oct-17-2018

(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.


RE: How to display <IPython.core.display.HTML object>? - pythopen - Oct-17-2018

Got it. Thank you.


RE: How to display <IPython.core.display.HTML object>? - pramod08728 - May-06-2023

(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