how to display a python string as HTML in jupyter notebook

点点圈 提交于 2019-12-05 14:58:05

问题


In IPython notebook, I used to be able to display a python string that contains html as actual html, by using the HTML function from IPython's display module.

from IPython.display import HTML

In jupyter notebook the display module no longer exists. Does anyone know where I can find the HTML function?

I use Jupyter notebook 4.1, IPython 4.0.2 and Python 3.5.1 64 bit


回答1:


Use the function display

def bar():
    from IPython.display import display, HTML
    chart = HTML('<h1>Hello, world!</h1>')
    # or chart = charts.plot(...)
    display(chart)

bar()

source: http://suanfazu.com/t/jupyter-highcharts/13438/2



来源:https://stackoverflow.com/questions/36267578/how-to-display-a-python-string-as-html-in-jupyter-notebook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!