Pycharm debugging guide

PyCharm's debugging has two display modes, Debugger and Console.

Insert image description here
The Debugger displays the contents of each element in list form;
the Console is similar to the direct Run output.

Debugger mode


·The difference between Step Over and Step Into…

Debugging mode shortcut key meaning
Step Over F8 Debug a line of code without entering the sub-function; if there is no sub-function, the function is the same as Step Into
Step Into F7 Single step execution, enter sub-function
Step Into My Code Alt + Shift + F7 During the debugging process, if you want to follow the code step by step, you can just press F7 (Step Into), and sometimes it will be transferred to the source code for execution. At this time, through Step Into My Code, you can let debug return to your own code and continue to the code. Execute under
Force Step Into Alt + Shift + F7 Forced entry, you can enter anywhere during debugging
Step Out Shift + F8 Run all the code after the breakpoint; when single-stepping into the sub-function, use step out to execute the remaining part of the sub-function and return to the previous layer function
Run to Cursor Alt + F9 Centered is executed until it stops at the cursor; when used inside a loop, a loop is executed when clicked once


·Jump directly from the current breakpoint to the next breakpoint

The above description is based on single-step debugging. If the two breakpoints are far apart and it is time-consuming to execute them step by step, you can use Run–>Resume Program to jump directly to the next breakpoint.
Insert image description here


·Set parameter values ​​in debug mode

For example, if you loop a hundred times in total and want to skip the rest after the first loop, you can set the value of the loop variable i as shown below to skip the loop.
![Insert image description here](https://img-blog.csdnimg.cn/970453582e994cf28c8797c0c1b4787b.png



Console mode

In console mode we can more conveniently output some attributes we want to see.

Guess you like

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