Home > Backend Development > Python Tutorial > How to set breakpoint debugging in pycharm

How to set breakpoint debugging in pycharm

下次还敢
Release: 2024-04-03 22:51:25
Original
770 people have browsed it

Breakpoint debugging is a way to step through the code to help identify errors and problems. Breakpoints can be set in PyCharm in the following ways: click the code line number or press the F9 key to set it on the current line Breakpoints; use the "Toggle Breakpoint" icon from the Debug toolbar to set breakpoints; after starting debugging, press F8 to execute the code line by line, or press F6 to enter a function, view variables, and continue execution.

How to set breakpoint debugging in pycharm

How to set breakpoint debugging in PyCharm

Breakpoint debugging is done by setting breakpoints in the code A technique for executing code line by line. This helps identify and resolve bugs and issues in your code.

Set breakpoints

  1. Click the code line number: In the code editor, click the gray area next to the line number , a red circle will appear indicating that the breakpoint has been set.
  2. Use keyboard shortcuts: Press F9 or Ctrl F9 (Cmd on macOS F9) Set a breakpoint at the line where the current cursor is.
  3. From the Debug toolbar: Click the "Toggle Breakpoint" icon (the icon with a red circle) in the Debug toolbar to set a breakpoint on the current line.

View breakpoints

The set breakpoints will be displayed under the "Breakpoints" tab in the Debug toolbar. You can double-click a breakpoint to edit its properties, such as conditional breakpoints or ignore counts.

Debugging

  1. Run to the breakpoint: Press the F8 key or click in the Debug toolbar "Debug" icon to start debugging. This will execute the code until the first breakpoint is encountered.
  2. Step by step execution: Press the F7 key or click the "Step Over" icon in the Debug toolbar to execute the code line by line. Press the F6 key or click the "Step Into" icon to enter the function.
  3. Check variables: At the breakpoint, you can view the value of the variable under the "Variables" tab. You can also use the "Watch" window to monitor the value of a variable.
  4. Resume execution: Press the F9 key or click the "Resume" icon in the Debug toolbar to continue executing code, ignoring all other breakpoints.

Cancel a breakpoint

  1. Click the breakpoint circle: Click the breakpoint circle again to cancel it.
  2. Use keyboard shortcuts: Press F9 or Ctrl F9 (Cmd on macOS F9) to cancel the breakpoint on the line where the current cursor is located.
  3. From the Debug toolbar: Click the "Toggle Breakpoint" icon in the Debug toolbar to cancel the breakpoint on the current line.

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

Related labels:
source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template