Python 是否可以将一个单元格从一个 jupyter notebook 复制到另一个?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40309098/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to copy a cell from one jupyter notebook to another?
提问by Ahmad Sultan
I am trying to copy cells from one jupyter notebook to another. How this is possible?
我正在尝试将单元格从一个 jupyter 笔记本复制到另一个。这怎么可能?
采纳答案by Nikolai K.
This feature has been introduced in Jupyter Notebook 5.0.
Use pip install notebook --upgrade
to upgrade to the latest release.
此功能已在Jupyter Notebook 5.0 中引入。使用pip install notebook --upgrade
升级到最新版本。
Note that the old shortcuts C
, V
and X
work only for copying and pasting inside one notebook. In order to do it across tabs, you should use Ctrl-C
and Ctrl-V
(Cmd-C
and Cmd-V
on Mac).
需要注意的是旧的快捷方式C
,V
而X
工作只用于复制和一台笔记本电脑里面粘贴。为了跨选项卡执行此操作,您应该使用Ctrl-C
和Ctrl-V
(Cmd-C
和Cmd-V
在 Mac 上)。
回答by Pierre ALBARèDE
With jupyter 5.0.0, copy paste of one or many cells from one notebook to another works with Cmd C Cmd V (Mac).
使用 jupyter 5.0.0,将一个或多个单元格从一个笔记本复制粘贴到另一个使用 Cmd C Cmd V (Mac) 工作。
For copying many cells together, select the first one then the last one with shift arrow (up or down).
要将多个单元格复制到一起,请选择第一个,然后使用 shift 箭头(向上或向下)选择最后一个。
The tool bar does not work for this purpose.
工具栏不适用于此目的。
回答by Varun Pius Rodrigues
I have not done it myself though, but general practice is to avoid doing it as it can disturb the Cell JSON. It was not even possible until a few versions before. Recent Github posts has made it possible to do so though. Copy paste the cell in question to a code editor such as Atom or Sublime Text, make the changes you want to do and then paste it into the new Jupyter notebook. It should work.
虽然我自己没有这样做,但一般的做法是避免这样做,因为它会干扰 Cell JSON。在之前的几个版本之前,它甚至是不可能的。不过,最近的 Github 帖子使这样做成为可能。将有问题的单元格复制粘贴到代码编辑器(例如 Atom 或 Sublime Text),进行您想做的更改,然后将其粘贴到新的 Jupyter 笔记本中。它应该工作。
回答by Swapnil Agarwal
For windows-
Use Ctrl + Shift + C
to copy cells after selecting them using shift + arrow
keys.
对于 Windows-
用于Ctrl + Shift + C
在使用shift + arrow
键选择单元格后复制单元格。
Then, switch to the notebook to which you want to copy the selected cells and go to command mode in it by pressing Esc
key.
Then, use Ctrl + Shift + V
to paste the cells in that notebook.
然后,切换到要将所选单元格复制到的笔记本,并在其中按Esc
键进入命令模式。然后,使用Ctrl + Shift + V
粘贴该笔记本中的单元格。
Note-I have not tested this on Linux but should work just as the procedure above.
注意 -我没有在 Linux 上测试过这个,但应该像上面的过程一样工作。
回答by Siva Kumar
You can download the cell content as .py file from jupier and then you can copy and paste wherever you want
您可以从 jupier 下载单元格内容为 .py 文件,然后您可以复制并粘贴到您想要的任何位置