我喜欢 IPython 的 Markdown 单元格,用于在笔记本中合并 HTML 和其他丰富的内容。我想知道命令输出是否可以在输出单元格中进行类似的格式化。
这是我输出 HTML 的函数之一:
print_html():
print """
<h2>Matplotlib's chart gallery (Click a chart to see the code to create it)</h2><br>
<div align="center"> <iframe title="Matplotlib Gallery" width="950"
height="250" src="http://matplotlib.org/gallery.html#api" frameborder="0"
allowfullscreen></iframe></div>
"""
上面的 HTML 代码,如果放在 markdown(输入)单元格中,会生成到 Matplotlib 库的很好的链接。但在输出单元格中,它只是纯文本。有什么办法让它丰富的内容?