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

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

我可以使用以下代码创建一个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()

可能是重复的问题,与如何将HTML嵌入iPython输出的问题相似。 (https://dev59.com/Al8e5IYBdhLWcg3wfaYy) - Ciro Santilli OurBigBook.com
2个回答

9

使用这个

from IPython.display import HTML

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

7
您需要调用IPython的HTML函数:
 HTML(s.set_table_attributes("border=1").render())

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接