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

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

问题描述

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

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

如何隐藏NBviewer呈现的笔记本中的所有代码,以便只输出代码(例如情节和表格)和降价单元格显示?

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笔记本中的单元格中的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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