在Jupyter笔记本中显示.html文件的输出

时间:2016-11-07 17:57:21

标签: python jupyter-notebook

我可以使用以下代码创建一个html文件:

with open(file_loc+'file.html', 'w') as html:
    html.write(s.set_table_attributes("border=1").render())

如何在不创建文件的情况下在Jupyter笔记本中显示输出?

如果我只是尝试在Jupyter中渲染它(如下所示),那么它会显示html代码而不是显示我在浏览器中看到的所需输出:

from IPython.core.display import display, HTML
s.set_table_attributes("border=1").render()

2 个答案:

答案 0 :(得分:3)

您需要调用IPython的HTML函数:

 HTML(s.set_table_attributes("border=1").render())

答案 1 :(得分:2)

使用此

from IPython.display import HTML

HTML(filename="profiling/z2pDecisionTreeProfiling.html")