IPython %save 魔法错误

标签 ipython ipython-notebook

我正在尝试使用 %loadpy 保存我加载到我的 IPython 笔记本中的 python 文件。魔法。当我尝试使用 %save settings.py 保存文件时我收到以下错误:

File `settings.py` exists. Use `%save -f 'settings.py' -f` to force overwrite

然后当我使用 %save -f 'settings.py' -f我收到错误:
'-f' was not found in history, as a file, url, nor in the user namespace.
%save -f 'settings.py'产生错误 '' was not found in history, as a file, url, nor in the user namespace.以及。

知道如何正确保存 .py文件,以便它覆盖以前的版本?谢谢!

最佳答案

In [13]: %save -f settings.py 1-10 # saves lines 1 to 10 to settings.py
In [14]: %save? # Gives you the help on the save command


Usage:
  %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ...

n1-n2、n3-n4 是要保存的行范围。 n5、n6 是您要保存的单个行号。添加 -f强制保存选项。

关于IPython %save 魔法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17034910/

相关文章:

ubuntu - 如何设置 ipython 工作目录?

python - 理解 Pandas 数据框中的数学错误

ipython - anaconda ipython 笔记本未在服务器设置中启动

python - 如何从 Jupyter 4.x 获取 IPython 配置文件行为?

python - python : Python 3 and 2 in IPython/Jupyter Notebook

python - 用于改变 Bokeh 图像图中使用的切片的交互式 slider

macos - 自从在Mac OS X Yosemite上安装python 3以来,ipython Notebook无法启动

python - 如何在 iPython QtConsole (Anaconda) 中删除数据框显示的边框?

ipython - 有什么方法可以在编辑模式、Jupyter Notebook 中交换 Enter 和 Shift-Enter 输入命令?

python - 想要在 Jupyter Notebook (Anaconda) 中保存并运行 Python 脚本