-r: use 'raw' input. By default, the 'processed' history is used,
so that magics are loaded in their transformed version to valid
Python. If this option is given, the raw input as typed as the
command line is used instead.
-f: force overwrite. If file exists, %save will prompt for overwrite unless -f is given.
-a: append to the file instead of overwriting it.
This function uses the same syntax as %history for input ranges, then
saves the lines to the filename you specify.
It adds a '.py' extension to the file if you don't do so yourself, and
it asks for confirmation before overwriting existing files.
If -r option is used, the default extension is .ipy. File:
~/anaconda3/lib/python3.5/site-packages/IPython/core/magics/code.py
从jupyter qtconsole,您可以使用
%save
魔术来保存您的工作。它比我想要的更麻烦,因为您必须指定要保存的输入单元格,但仍然非常方便。在例如,要将输入单元格2到7保存到名为
MyCommands.py
的文件中,只需键入将文件保存在当前工作目录中。如果文件已经存在,它甚至会警告你并要求确认。在
有关更多信息,请使用jupyter极其有用的内置帮助功能,方法是在需要帮助的项目后添加问号。在
^{pr2}$它打印docstring
请注意,您可以使用问号来研究带有docstring的任何函数或对象(即
enumerate?
,range?
)。在相关问题 更多 >
编程相关推荐