繁体   English   中英

在 vscode 中的非笔记本 python 文件中创建 jupyter 单元的快捷方式

[英]Shortcut to creating a jupyter cell in a non-notebook python file in vscode

这可能是这里最愚蠢的问题,但我记得有一个 3 个字符串,它会在 vscode 的非笔记本 python 文件中声明一个 jupyter 单元格,我似乎不记得它是什么,到目前为止我没有尝试过给出一个搜索引擎结果,我记得是##请帮忙

如果你想在 .py 文件中创建一个 ipynb 单元,它需要如下所示:

some code
....
....

# %%
text = "this code is now in a cell and can be run on it's own"
print(text)

# %%
# add another '# %%' before the rest of the code in your .py file so the cell above is isolated and can be run on it's own without running the rest of the program

more code 
...
...
...

暂无
暂无

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

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