如何从使用 nbviewer 可视化的 ipython notebook 中的单元格隐藏代码? [英] How to hide code from cells in ipython notebook visualized with nbviewer?

查看:32
本文介绍了如何从使用 nbviewer 可视化的 ipython notebook 中的单元格隐藏代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 NBviewer 可视化的 ipython/jupyter 笔记本.

I have an ipython/jupyter notebook that I visualize using NBviewer.

如何隐藏 NBviewer 呈现的笔记本中的所有代码,以便仅显示代码输出(例如绘图和表格)和 Markdown 单元格?

How can I hide all the code from the notebook rendered by NBviewer, so that only the output of code (e.g. plots and tables) and the markdown cells are shown?

推荐答案

from IPython.display import HTML

HTML('''<script>
code_show=true; 
function code_toggle() {
 if (code_show){
 $('div.input').hide();
 } else {
 $('div.input').show();
 }
 code_show = !code_show
} 
$( document ).ready(code_toggle);
</script>
<form action="javascript:code_toggle()"><input type="submit" value="Click here to toggle on/off the raw code."></form>''')

这篇关于如何从使用 nbviewer 可视化的 ipython notebook 中的单元格隐藏代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆