jupyter notebook与Python Console/Terminal

Pycharm

Terminal (command terminal) in Pycharm is in command mode (equivalent to opening cmd in the directory where the currently opened file is located, the same usage as Windows DOS, for environment switching, pip command installation, etc.)


In Pycharm's Python Console, press Enter after typing the code to run it line by line. You can also press shift+Enter after typing a line to run in any block of lines.

Advantages of console: Each variable attribute can be displayed.
Disadvantages: Not conducive to code reading and modification.

In addition to the console, you can also quickly see the attributes of each variable through breakpoint debugging.


Another small use of the console: when you want to try certain functions, you can test them directly in the console without having to go to the trouble of opening a new python project for testing.

What you need to know about Pycharm: Settings→Keymap (can set and view shortcut keys for various operations)
alt+7: Shortcut key for Structure (in the lower left corner of the main page)
ctrl+shift+f: Global search
ctrl+shift+r: global replacement

As shown below, in this position in Settings, you can set the completion code to ignore case.
Insert image description here

Place the mouse in the formal parameter brackets of the function and press ctrl+p: View the formal parameters required by the current function


When encountering the error "Unindent does not match any outer indentation level" in Pycharm,
in addition to deleting the indentation of the corresponding line of code and retyping,
you can also select the code directly with the shortcut key Ctrl+Alt+L (formatting code shortcut keys, many When the application grabs this shortcut key, sometimes it may lock the screen when pressed, so you can modify this shortcut key as follows)
Open the top menu File->Setting, select Keymap, and find Reformat Code in Main Menu/Code. (It is also very fast to search Reformat Code directly in the search box.)
Right-click the mouse to select Reformat Code, first Remove Ctrl+Alt+L, and then Add Keyboard Shortcut.
Just press Ctrl+Alt+; in the pop-up window (of course you can also set it to any non-conflicting shortcut key you like) and save it all the way.


Jupyter

Use the following command in cmd

Jupyter notebook

Note: If you enter the Jupyter notebook command in cmd to open it, it will be opened in the directory displayed before the Jupyter notebook command by default.

If Jupyter notebook cannot run the code, it is often because the pyzmq version is too high and is incompatible with Jupyter Notebook.
Solution
1. Open Anaconda Prompt, enter the following code to delete the original pyzmq
conda uninstall pyzmq
2. Enter the following code to install a lower version of pyzmq
conda install pyzmq==19.0.2

Jupyter notebook shortcut key
Double-click D: delete the entire block
ctrl+enter: run this block of code
Shift + Enter: Run the current code block and jump to the next code block

Guess you like

Origin blog.csdn.net/m0_50364811/article/details/126674078