- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
此问题已针对 Jupyter 笔记本提出并回答 here 。还有一项关于 JupyterLab 的建议,以及如何隐藏单元格输出,但不清除它。
使用编辑>清除输出
下的菜单很容易做到这一点。但是如何使用键盘快捷键来做到这一点呢? Edit
下的许多其他命令已经有自己指定的快捷方式,但不是这个:
最佳答案
答案:
您必须在设置 > 高级设置编辑器
下分配自定义快捷键,方法是在用户首选项
下插入以下内容:
{// List of Keyboard Shortcuts
"shortcuts": [
{
"command": "notebook:clear-cell-output",
"keys": [
"F10"
],
"selector": ".jp-Notebook.jp-mod-editMode"
},
]
}
我选择了F10
,但大多数其他键或组合键也应该可以工作。我还使用过 Ctrl Shift Enter
。
放置位置:
一些细节:
如果您分配了其他快捷方式,请确保将其添加到其他快捷方式列表中的正确位置。
{// List of Keyboard Shortcuts
"shortcuts": [
{
"command": "notebook:run-in-console",
"keys": [
"F9"
],
"selector": ".jp-Notebook.jp-mod-editMode"
},
{
"command": "notebook:clear-cell-output",
"keys": [
"F10"
],
"selector": ".jp-Notebook.jp-mod-editMode"
},
]
}
还有一点神秘:
如果您插入与第二个框中完全相同相同的内容,您将看到Run > Run Selected Text or Current Line in Console
项已获得就在它旁边,很好的F9
:
不会项目编辑 > 清除输出
就是这种情况,我不得不说我不会知道为什么。
据我所知,您分配给所选键盘快捷键的 "command": "notebook:clear-cell-output"
应该就是这个功能。但好处是它的工作原理完全一样。至少对我来说是这样。
请注意,此方法最适合较新版本的 JupyterLab。对于旧版本,正确的方法会有点不同。
这是一个可以立即测试的 python 代码片段:
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randint(0,100,size=(100, 4)), columns=list('ABCD'))
print(df)
关于python - JupyterLab : How to clear output of current cell using a keyboard shortcut?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60319271/
我是一名优秀的程序员,十分优秀!