本文介绍了如何在jupyter笔记本上将python脚本另存为.py文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Jupyter笔记本上编写了一些函数,并希望将脚本保存为.py格式,但是anaconda jupyter笔记本会自动将脚本另存为.ipynb,如何针对此特定脚本将其更改为.py?有任何命令吗?谢谢

I wrote some functions on Jupyter notebook and want to save the script in form of .py, but anaconda jupyter notebook automatically saves the script as .ipynb, How can I change it to .py for this specific script? Is there any command for it? Thanks

推荐答案

Jupyter中的内置Magic命令:

魔术作为有用的函数非常有用,而Python语法却没有 最自然的一种,或者当一种想要嵌入无效的python语法时 在他们的工作流程中.

Magics are useful as convenient functions where Python syntax is not the most natural one, or when one want to embed invalid python syntax in their work flow.

%% writefile (写出单元格保存到文件)

%%writefile (Write the contents of the cell to a file)

%save (保存一组行或给定文件名的宏)

%save (Save a set of lines or a macro to a given filename)

这篇关于如何在jupyter笔记本上将python脚本另存为.py文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 08:55