Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 如何将多行输入粘贴到Jupyter控制台?_Macos_Ipython_Jupyter_Ipython Magic - Fatal编程技术网

Macos 如何将多行输入粘贴到Jupyter控制台?

Macos 如何将多行输入粘贴到Jupyter控制台?,macos,ipython,jupyter,ipython-magic,Macos,Ipython,Jupyter,Ipython Magic,用于粘贴多行输入的%paste magic适用于IPython 2,但在Jupyter控制台(在Mac OSX El Capitan上)中失败 查看列出所有magic命令的%lsmagic的输出时,确实没有显示%paste 我试图直接粘贴,但是缩进被弄乱了,所以很明显需要像%粘贴这样的东西。检查(仅在5天前更新)时,甚至没有提到“粘贴”一词 那么,如何将多行输入粘贴到控制台?好的。找到了解决办法。Jupyter控制台有一个%cpaste magic,它的行为与以前的%paste稍有不同,但可以完

用于粘贴多行输入的%paste magic适用于IPython 2,但在Jupyter控制台(在Mac OSX El Capitan上)中失败

查看列出所有magic命令的%lsmagic的输出时,确实没有显示%paste

我试图直接粘贴,但是缩进被弄乱了,所以很明显需要像%粘贴这样的东西。检查(仅在5天前更新)时,甚至没有提到“粘贴”一词


那么,如何将多行输入粘贴到控制台?

好的。找到了解决办法。Jupyter控制台有一个%cpaste magic,它的行为与以前的%paste稍有不同,但可以完成任务

%cpaste:
Paste & execute a pre-formatted code block from clipboard.

You must terminate the block with '--' (two minus-signs) or Ctrl-D
alone on the line. You can also provide your own sentinel with '%paste
-s %%' ('%%' is the new sentinel for this operation).

The block is dedented prior to execution to enable execution of method
definitions. '>' and '+' characters at the beginning of a line are
ignored, to allow pasting directly from e-mails, diff files and
doctests (the '...' continuation prompt is also stripped).  The
executed block is also assigned to variable named 'pasted_block' for
later editing with '%edit pasted_block'.

You can also pass a variable name as an argument, e.g. '%cpaste foo'.
This assigns the pasted block to variable 'foo' as string, without
dedenting or executing it (preceding >>> and + is still stripped)

'%cpaste -r' re-executes the block previously entered by cpaste.
'%cpaste -q' suppresses any additional output messages.

Do not be alarmed by garbled output on Windows (it's a readline bug).
Just press enter and type -- (and press enter again) and the block
will be what was just pasted.

IPython statements (magics, shell escapes) are not supported (yet).

See also
--------
paste: automatically pull code from clipboard.

Examples
--------
::

  In [8]: %cpaste
  Pasting code; enter '--' alone on the line to stop.
  :>>> a = ["world!", "Hello"]
  :>>> print " ".join(sorted(a))
  :--
  Hello world!

嗯。找到了解决办法。Jupyter控制台有一个%cpaste magic,它的行为与以前的%paste稍有不同,但可以完成任务

%cpaste:
Paste & execute a pre-formatted code block from clipboard.

You must terminate the block with '--' (two minus-signs) or Ctrl-D
alone on the line. You can also provide your own sentinel with '%paste
-s %%' ('%%' is the new sentinel for this operation).

The block is dedented prior to execution to enable execution of method
definitions. '>' and '+' characters at the beginning of a line are
ignored, to allow pasting directly from e-mails, diff files and
doctests (the '...' continuation prompt is also stripped).  The
executed block is also assigned to variable named 'pasted_block' for
later editing with '%edit pasted_block'.

You can also pass a variable name as an argument, e.g. '%cpaste foo'.
This assigns the pasted block to variable 'foo' as string, without
dedenting or executing it (preceding >>> and + is still stripped)

'%cpaste -r' re-executes the block previously entered by cpaste.
'%cpaste -q' suppresses any additional output messages.

Do not be alarmed by garbled output on Windows (it's a readline bug).
Just press enter and type -- (and press enter again) and the block
will be what was just pasted.

IPython statements (magics, shell escapes) are not supported (yet).

See also
--------
paste: automatically pull code from clipboard.

Examples
--------
::

  In [8]: %cpaste
  Pasting code; enter '--' alone on the line to stop.
  :>>> a = ["world!", "Hello"]
  :>>> print " ".join(sorted(a))
  :--
  Hello world!

这不是jupyter控制台而是ipython,所以你没有回答这个问题这不是jupyter控制台而是ipython,所以你没有回答这个问题