jupyter writefile魔术写法 快捷的文件写法

Published on Aug. 22, 2023, 12:11 p.m.

写入到python文件

%%writefile myfile.py
def my_function():
    print("Hello from a function")

这种方案对于写入配置文件和临时文件来说还是很简单的。

参考链接
Hack: How To Create Files From Jupyter
https://predictivehacks.com/hack-how-to-create-files-from-jupyter/
Built-in magic commands
https://ipython.readthedocs.io/en/stable/interactive/magics.html