我正在寻找一种在VSCode中将.ipynb转换为.py文件的好方法。到目前为止,我已经尝试:
"To add a new cell, type '# %%' To add a new markdown cell, type '# %% [markdown]' %% from IPython import get_ipython"
nbconvert。我通常将其作为命令插入脚本本身(https://stackoverflow.com/a/19779226/14198216),以便在运行时自动转换和保存。但这也会留下“运行单元”等,以及执行标记(例如:“In[1]”)
jupytext。我通常也会将其作为命令插入。在.py的开头,它生成:
-- coding: utf-8 -- --- jupyter: jupytext: text_representation:
有没有一个好的、极简主义的解决方案,它不会在我的笔记本的.py版本中插入一堆乱七八糟的东西(需要手动编辑),并且可以从笔记本本身轻松/自动执行?这也可能是设置一些我目前还不知道的调整,可以使我提到的其中一项工作做得更好
提前谢谢
我们可以在“
settings.json
”中添加以下设置,生成的python文件将不会有“运行单元格”、“运行在上面”、“调试单元格”:我发现有一种方法可以直接在VS代码中导出:
https://code.visualstudio.com/docs/python/jupyter-support-py
相关问题 更多 >
编程相关推荐