7

我正在尝试使用%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文件以覆盖以前的版本吗?谢谢!

4

1 回答 1

10
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 are ranges of lines that you want to save. n5, n6 are individual line numbers that you want to save. Add -f option to force save.

于 2013-06-13T14:11:54.280 回答