我正在尝试使用 %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/