Pycharm debug program, jump to the specified loop condition/number of loops

Right click on the breakpoint and set the condition 

 

example

for i in range(1,100):
    a = i + 1
    b = i + 2
    print(a, b, i)

Note :

1. You should debug the breakpoint at the position after the loop instead of the position on the loop , and then you can set your conditions to enter the specified loop

2. To set the condition, use the equal symbol "==" instead of the assignment symbol "="

3. At the position where the breakpoint condition is set, the condition should be a variable that has appeared. For example, the setting "a==15" below is correct, but "b==15" is wrong, because b has not been executed before this line. Appear

Set the condition during the running process, so as to run directly to this conditional loop without re-debugging

For example, you have set a breakpoint at this time, but you have not set a breakpoint condition. At this time, i=1 is the first loop

 At this point you want to switch to the 15th loop, which is the condition "I==15", then you don't need to debug again, but just set the loop condition in this run, and then directly "Step out" [ Shift + F8]

 Successfully entered the 15th loop:

Guess you like

Origin blog.csdn.net/weixin_43135178/article/details/131995955