【pycharm】【基本的代码调试】

本文介绍了如何有效使用PyCharm的调试器,包括设置断点、使用调试工具窗口、控制执行流程,以及在代码中步进操作,帮助开发者高效地查找和修复代码错误。
摘要由CSDN通过智能技术生成

目录

Basic Code Debugging 

基本的代码调试

1 How to use PyCharm's debugger effectively.

1 如何有效使用PyCharm的调试器

2 Breakpoints and Debug Session

2 中断点和调试任务

3 Debug Tool Window

3 调试工具窗口

4 Debugger and Console Tab

4 “日志记录器和控制台”选项卡

5 Step Through 

5 步进

6 Conclusion 

6 结论

Basic Code Debugging 

基本的代码调试

1 How to use PyCharm's debugger effectively.

1 如何有效使用PyCharm的调试器

In this step, we’ll look at PyCharm’s debugger, specifically how to use it to walk through your running code and to help you find and fix bugs.
在这一步中,我们将研究PyCharm的调试器,特别是如何使用它来遍历运行中的代码,并帮助您查找和修复bug。

2 Breakpoints and Debug Session

2 中断点和调试任务

Everything starts with a breakpoint. Breakpoints are markers that tell the debugger to suspend the execution of a program. To add and remove breakpoints click the gutter in the line where you want to add them. You can also add a breakpoint from the keyboard by leaving the caret at the end of the line and pressing ⌘F8 (macOS) / Ctrl+F8 (Windows/Linux).
一切都始于一个断点。断点是告诉调试器挂起程序执行的标记。若要添加和删除断点,请单击要添加断点的行中的分隔线。您还可以通过在行尾保留插入符号并按#0 #(macOS)/#1 #(Windows/Linux)从键盘添加断点。

In this example we are adding a breakpoint to this if statement inside our loop, so the program will suspend the execution on each iteration. We can run the program with the debugger by clicking the little bug button at the top of PyCharm. This runs the currently-selected configuration, but under the debugger.
在这个例子中,我们在循环中给这个 if 语句添加了一个断点,所以程序将在每次迭代中挂起执行。我们可以通过单击PyCharm顶部的小bug按钮来运行调试器程序。这将运行当前选定的配置,但在调试器下。

Debug Icon

This project was made from the Flask project template, so it had a Flask Run Configuration made from the start. Another way to run the program with the debugger is to right-click inside the editor and select Debug nam

  • 16
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

资源存储库

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值