agc*_*nti 4 javascript python ipython ipython-notebook
我正在IPython Notebook中创建一个Django教程,我希望在教程进行过程中使用%save魔术保存.py文件来创建/编辑/推进网站.问题在于%save通过指定要保存的行来实现神奇.毫无疑问,当用户在文件乱序或多次执行单元格时,行号将发生变化.
我想这样工作:
some .py file imported into the notebook.
# do all sorts of website things
%save -f this.py file
Run Code Online (Sandbox Code Playgroud)
它将保存单元格的内容而不需要行号.有没有办法用%save魔法的现有功能来做到这一点?
在与IPython开发团队交谈后,minrk找到了答案:
%%writefile filename.py
Run Code Online (Sandbox Code Playgroud)
会在单元格中写下它下面的所有内容filename.py.链接到对话.