How to hide one specific cell (input or output) in IPython Notebook?

后端 未结 10 1531
伪装坚强ぢ
伪装坚强ぢ 2020-11-29 21:53

Is there a way to selectively hide one specific input or output cell in IPython notebook?

I could only find the below code to show / hide all input cells.

h

10条回答
  •  孤街浪徒
    2020-11-29 22:27

    The @Mathmagician solution is almost perfect, but has many side effects.

    More correct would be like:

    from IPython.core.display import display, HTML
    toggle_code_str = '''
    
    ''' toggle_code_prepare_str = ''' ''' display(HTML(toggle_code_prepare_str + toggle_code_str)) def toggle_code(): display(HTML(toggle_code_str))

    The call toggle_code than may be placed in some code cell before other code, so if code in the cell is executed slowly, won't be side effects. Also it solves the problem with Run Cells and Select/Insert Below

    It adds the toggle button, but the initial state can't be managed

提交回复
热议问题