简体   繁体   English

如何在 VSCode 的笔记本编辑器中打开 .py 文件

[英]How do I open a .py file in the notebook editor of VSCode

VSCode has a notebook editor that works for .ipynb files. VSCode 有一个适用于.ipynb文件的笔记本编辑器。 Is it possible to open a regular .py file (optionally annotated with the "percent" syntax) in the integrated notebook editor?是否可以在集成的笔记本编辑器中打开常规的.py文件(可选地用“百分比”语法注释)? If yes, how?如果是,如何?

Right clicking the file in the editor or the file explorer gives no option of opening with the notebook editor.右键单击编辑器或文件资源管理器中的文件不会提供使用笔记本编辑器打开的选项。 Also running the "Open in Notebook Editor" and "Open in Preview Notebook Editor" commands from the Command Palette doesn't seem to do anything.同样从命令面板运行“在笔记本编辑器中打开”和“在预览笔记本编辑器中打开”命令似乎没有做任何事情。

Only reference I could find is the following, however that refers to .ipynb only: https://code.visualstudio.com/docs/python/jupyter-support#_create-or-open-a-jupyter-notebook我能找到的唯一参考如下,但仅指.ipynbhttps://code.visualstudio.com/docs/python/jupyter-support#_create-or-open-a-jupyter-notebook

I'm a developer on this extension.我是这个扩展的开发者。 The notebook editor is just for opening up Notebook (.ipynb) files. Notebook 编辑器仅用于打开 Notebook (.ipynb) 文件。 .py files will open up in the normal VSCode editor. .py 文件将在普通的 VSCode 编辑器中打开。 However if you have code cell (#%%) annotations in your.py file you should have both CodeLenses and command palette commands that you can use to run blocks of code in jupyter.但是,如果您的 .py 文件中有代码单元 (#%%) 注释,您应该同时拥有 CodeLenses 和命令调色板命令,您可以使用它们在 jupyter 中运行代码块。 The output from those blocks will show up in an interactive window that is similar to the notebook editor.这些块中的 output 将显示在类似于笔记本编辑器的交互式 window 中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM