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

Show output of .html file in Jupyter notebooks

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

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

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

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

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

您需要调用 IPython 的 HTML 函数:

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

使用这个

from IPython.display import HTML

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