我目前正在尝试使用 ipython 在 jupyter 实验室笔记本中显示一些 HTML。我有一种工作方式,但是它需要我将 html 文件推送到 github 以获得 github 页面,然后在 jupyter 实验室内呈现链接。
有效的代码:
IFrame(src='https://aasnani.github.io/test/', width=900, height=600)
但是,我试图让它在本地工作,而不必将文件推送到 GitHub。
我试过了:
IPython.display.IFrame(src=base_path + 'MN_Map.html', width=900, height=600)
IPython.display.HTML(filename=base_path + 'MN_Map.html')
IFrame(src=base_path + 'MN_Map.html', width=900, height=600)
HtmlFile = open(base_path + 'MN_Map.html', 'r', encoding='utf-8')
source_code = HtmlFile.read()
display(HTML(source_code))
这些都不起作用。我还在 jupyter 实验室中启用了 gmaps 和 nbextensions。有人可以解释为什么第一种方法有效而其他方法无效吗?您可以从 github 链接本身 here 或存储库 here 中获取 html 文件。
先谢谢你!