Summary of Jupyter notebook Shortcut Keys in Python

  • 2021-10-27 07:52:24
  • OfStack

1. Command mode (press Esc key):

Enter: Go to edit mode Shift-Enter: Run this cell and select the next cell Ctrl-Enter: Run this module Alt-Enter: Run this cell and insert a new cell under it Y: Cell goes to code state M: Cell goes to markdown state R: Cell goes to raw state

2. Editing mode:

Tab: Code completion or indentation Shift-Tab: Hint Ctrl-]: Indent Ctrl-[: Unindent Ctrl-A: All selected Ctrl-Z: Recovery Ctrl-Shift-Z: Do it again

3. After all cell of Jupyter notebook has been run, the variables in the cell are saved in memory. If the previous variables are modified in cell, problems may occur when running the cell here.

For example, the following code:


#  No. 1 1 A cell Code in 
a = 10
b = 20
 
#  No. 1 2 A cell Code in 
c = a/b
b = 0

Because the second cell modifies the b variable, b is equal to 0 in the whole environment, a/b will have problems when cell is run later. Kernel can be used in this case- > Restart & RunAll rerun the entire project.


Related articles: