Step into, Step over, Step out区别

Step into: Single step execution (execution of code line by line), if you encounter a sub-function, it will enter the sub-function, and continue to single-step execution. That is, every line of code that needs to be executed is not skipped, and proceeded line by line.

Step over: During single-step execution, if a sub-function is encountered, the sub-function will not be entered, but the sub-function will be executed as a whole step, so as to continue to execute the code under the function call position.

Step out: When stepping into a sub-function, use Step out to execute the remaining part of the sub-function and return to the previous function.

It should be noted that if there is a breakpoint in the following code, Step over and Step out will not skip the breakpoint, that is, the position of the breakpoint will definitely "break".

Example: The
code is as follows

def add(a ,b):
    c = a + b
    return c


def divide(a ,b):
    d = a / b
    return d


def debug_study():
    i = 10
    j = 5
    Sum = add(i, j)
    Divided = divide(i, j)
    print(Sum, Divided)


if __name__ == '__main__':
    debug_study()

As shown in the figure, using PyCharm, add breakpoints on lines 2, 14, and 16.
Insert picture description here
Click on the little crawler shown below to start debugging.
Insert picture description here
Insert picture description here

The following is the position where the debugger stays each time Step into, Step over and Step out are used continuously after Debug is turned on.
Step into: 14 2 3 14 15 7 8 15 16 20 end
Step over: 14 2 3 14 15 16 20 end
Step out: 14 2 14 16 20 end

Guess you like

Origin blog.csdn.net/weixin_43529394/article/details/113666422