Home  >  Article  >  Backend Development  >  How to debug breakpoints in pycharm

How to debug breakpoints in pycharm

下次还敢
下次还敢Original
2024-04-18 11:48:151281browse

Perform breakpoint debugging in PyCharm, including: opening the debugging toolbar; setting breakpoints (click on the blank line number area on the left); starting debugging (debugger drop-down menu); executing code step by step (Step Over , Step Into, Step Out); view variables and expressions (hover or enter the debugger variables pane); continue debugging (continue button or F9); delete breakpoints (click the red dot or use "Delete all breakpoints" ” button).

How to debug breakpoints in pycharm

How to do breakpoint debugging in PyCharm

Breakpoint debugging is a powerful tool that can help You step through the code and identify problems. To set breakpoints in PyCharm, you can follow these steps:

1. Open the debugging toolbar

Click "Run" in the menu bar> "Debug", or use the shortcut "Ctrl Alt Shift D" (Windows) or "Cmd Option Shift D" (Mac).

2. Set a breakpoint

On the line where you want the code to stop executing, click the blank line number area to the left. When a red dot appears around the line number, it indicates that a breakpoint has been set.

3. Start debugging

Click the "Debugger" drop-down menu in the debug toolbar and select "Debug" or "Debug 'filename.py'" . PyCharm will execute the code starting from the breakpoint line.

4. Step through code

When the code stops at a breakpoint, you can step through it using the buttons in the debug toolbar:

  • Step Over (F8): Execute the current line without entering the function.
  • Step Into (F7): Function that enters the current line.
  • Step Out (Shift F7): Exit the current function.

5. View variables and expressions

To view a variable or expression, hover over it in the code or in "Debugger Variables" Enter its name in the pane. You can also right-click a variable and select Evaluate Expression to evaluate an expression in the Console.

6. Continue debugging

You can use the "Continue" button or the shortcut key "F9" to continue executing the code until the next breakpoint or the end of the code.

7. Delete a breakpoint

To delete a breakpoint, click the red dot in the line number area again. You can also delete all breakpoints using the "Delete All Breakpoints" button in the debug toolbar.

The above is the detailed content of How to debug breakpoints in pycharm. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn