jupyter notebook最最常用的快捷键

先记住熟练应用以下几个快捷键。

1.进入命令模式  快捷键ESC (鼠标左击单元格左端也可以)

jupyter notebook最最常用的快捷键

单元格左端变蓝色,进入命令模式,此时(已松开ESC键)可以按命令快捷键(实践表明大小写没看到区别,效果一样)

m进入markdown标记模式       y代码编写模式    a在当前单元格之前插入一个空单元格    b 在当前之后插单元格

按回车键(或鼠标单击单元格中部也可以),进入编辑模式)

单元格左端变绿色:

jupyter notebook最最常用的快捷键

再按m,当前单元格(官方翻译叫做代码块)转换为markdown格式。
按esc进入命令模式,按y,当前单元格转换为代码。

m和markdown是首字母关系,y和code有什么关系呢,为什么用y,不用c,实际上c已经名花有主了
官方提示,以及众多博客,都是给的大写M,这里不区分大小写…

通用规则:

esc,y :先按esc,再按y
esc+c :一起按

2. 运行单元格:ctrl,shift,alt    + Enter

ctrl+Enter,运行当前单元格,不移动,适合调试多行代码时用,不必移动

shift+enter运行当前单元格,并移至下一格,但不新建.  适合逐步验证多个单元格代码时

alt+enter 运行单元格,在下方新建并移至新单元格,较适合边看教程边练习用.

 

3. shift+Tab 工具提示

类似在vscode中使用ctrl+鼠标左键,可以查看进入函数内部,查看参数列表、示例等。
与此类似,在notebook中使用shift+Tab可以显示工具提示
用法:鼠标点击到要看的函数上,shift+tab
举个栗子:
matplotlib.pyplot中绘制直方图,函数hist()参数很多,功能很多。用到的时候,不免忘记了有哪些功能、各个参数代表什么意思。jupyter notebook最最常用的快捷键

density不是密度吗,密度和直方图有什么关系?
参数解释:

density : bool, optional. If True, the first element of the return tuple will be the counts normalized to form a probability density, i.e.,the area (or integral) under the histogram will sum to 1.This is achieved by dividing the count by the number of observations times the bin width and not dividing by the total number of observations. If stacked is also True, the sum of the histograms is normalized to 1.
Default is None for both normed and density. If either is set, then that value will be used. If neither are set, then the args will be treated as False.If both density and normed are set an error is raised.

这解释在vscode并没有看到(估计还是没用到应该的快捷键),总之,这里的解释很到位,超级赞!

4. ESC,h 查看快捷键列表

(1)Jupyter Notebook帮助文档学习

按一下ESC键,再按一下h,则出来如图各快捷键供查阅:

jupyter notebook最最常用的快捷键
(2)help选项下有常用包的官方文档:

碰到相关问题,先查看官方文档,特别是查看示例(examples),帮助很大。
例如matplotlib的官方文档,各个函数有详细的解释和示例.

jupyter notebook最最常用的快捷键

 



参考:https://blog.****.net/houhuipeng/article/details/90490104